User Tools

Site Tools


led_serialread_arduino

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

led_serialread_arduino [2014/01/23 11:59] (current)
zoza created
Line 1: Line 1:
 +LED serial read > arduino code
  
 +<code c++>
 +
 +    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);​
 +    }
 +    }
 +</​code>​
led_serialread_arduino.txt ยท Last modified: 2014/01/23 11:59 by zoza