Last active
January 17, 2017 09:28
-
-
Save dkrkamesh/ab14ba8c9b75e285de087fe0c8578929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source Code: Raspberry Pi sending data to the Arduino | |
const int ledPin = 13; | |
void setup() | |
{ | |
pinMode(ledPin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
if (Serial.available()) | |
{ | |
blink(Serial.read() - '0'); // convert the character '1'-'9' to decimal 1-9 | |
} | |
delay(500); | |
} | |
void blink(int numberOfTimes) | |
{ | |
for (int i = 0; i < numberOfTimes; i++) | |
{ | |
digitalWrite(ledPin, HIGH); | |
delay(100); | |
digitalWrite(ledPin, LOW); | |
delay(100); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment