User Tools

Site Tools


led_serialread_arduino

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