Keresés

Hirdetés

Új hozzászólás Aktív témák

  • Gergosz2

    veterán

    válasz Saua #1521 üzenetére

    de volt olyan, hogy a program pl <d2122>-t küldött?

    Ha nem akkor próbáld meg, hogy a while ciklusból kiveszed a delay-t. Ha az sem megy akkor ezt próbáld meg:

    #include <SoftwareSerial.h>
    int bluetoothTx = 2;
    int bluetoothRx = 3;
    int ledPin = 11;
    SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

    String readString;
    bool ok=false;
    void setup() {
    Serial.begin(9600);
    bluetooth.begin(9600);
    }

    void loop() {
    while (bluetooth.available()) {
    char c = bluetooth.read ();
    if (c != '<' && c != 'd' && c != '>' )
    {
    readString += c;
    }
    if (c=='>') {
    ok=true;
    }
    }

    if (ok==true) {
    int szam = readString.toInt();
    Serial.println(szam);
    readString = "";
    analogWrite(ledPin, szam);
    ok=false;
    }
    }

    [ Szerkesztve ]

    Nokia 6030 Hardcore User // I Panic Restaurant by Taito

Új hozzászólás Aktív témák