User Tools

Site Tools


led_serialread_arduino

Warning: Use of undefined constant PREG_PATTERN_VALID_LANGUAGE - assumed 'PREG_PATTERN_VALID_LANGUAGE' (this will throw an Error in a future version of PHP) in /var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line 633

Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line 633

LED serial read > arduino code

    int incomingByte = 0; // for incoming serial data
    int led = 8;

    void setup() {
    Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
    pinMode(led, OUTPUT);
    }

    void loop() {

    // send data only when you receive data:
    if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    analogWrite(led, incomingByte);
    }
    }
led_serialread_arduino.txt · Last modified: 2014/01/23 11:59 by zoza