Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[C/C++] kleines C Beispielprogramm läuft macht aber nix

Featured Replies

Geschrieben

hi, hab die wetterstation und wollte für die ein c programm schreiben, da ich mich mit c besser auskenne als mit python. ich nahm das kleine beispielprogramm aus der dokumentation um hellworld auf dem display auszugeben.

 

das Programm läuft auf meinem Raspberry pi 3, welcher via usb mit der wetterstation verbunden ist.

 

das programm läuft zwar durch, jedoch bleibt das display aus.

 

// kleines c/c++ programm zum anzeigen von messedaten auf dem lcd

#include <stdio.h>

// einbinden der Tinkerforge API

#include "ip_connection.h"
#include "bricklet_lcd_20x4.h"


// Definition der Schnittstelle
// UIDS 
//Master = O
// Ambient light = A
// LCD = B
//Humidity = C
// Barometer = D

#define HOST "localhost"
#define PORT 4223
#define UID "B"

int main (void)
{
        // erzeugen der ip verbindung
        IPConnection ipcon;
        ipcon_create(&ipcon);

        //erzeugen des Geraete Objekts
        LCD20x4 lcd;
        lcd_20x4_create(&lcd, UID, &ipcon);

        // Verbindung zur Station
        if(ipcon_connect(&ipcon, HOST, PORT) < 0)
        {
                fprintf(stderr, "kann nicht verbinden \n");
                return 1;
        }
        printf("habe mich verbunden  \n ");

        //Hintergrundbeleuchtung anschalten
        lcd_20x4_backlight_on(&lcd);
        printf("hab das lcd eingeschalten \n");

        printf("Enter zum beenden \n" );
        getchar();
        lcd_20x4_destroy(&lcd);
        ipcon_destroy(&ipcon);
        return 0;
}

 

die printf ausgaben sehe ich zwar im terminal doch passieren tut nix

Geschrieben

Du hast UID und Position durcheinander gebracht. Dein LCD Bricklet ist an Bricklet Port B am Master Brick angeschlossen. Du musst aber dessen UID angeben, nicht den Port.

 

Die richtige UID kannst du in Brick Viewer ablesen und ist typischer Weise für Bricklets 3 Zeichen lang, zum Beispiel: z5U.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.