Created
February 25, 2017 14:35
-
-
Save REPTILEHAUS/2168ad3316b8894609f1047a98bbbe32 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
/* | |
Script by @REPTILEHAUS | |
by Paddy O'Sullivan | |
*/ | |
// Assign each of our input pins to an integer variable | |
int LED_one = 13; | |
int LED_two = 12; | |
int LED_three = 11; | |
int LED_four = 10; | |
void setup() { | |
Serial.begin( 9600 ); | |
pinMode( LED_one, OUTPUT ); | |
pinMode( LED_two, OUTPUT ); | |
pinMode( LED_three, OUTPUT ); | |
pinMode( LED_four, OUTPUT ); | |
} //END OF SETUP | |
void loop() { | |
while (Serial.available() == 0); // wait until the serial connection is open | |
int COM_value = Serial.read() - '0'; //read from the serial connection; the - '0' is to cast the values as the int and not the ASCII code | |
Serial.println(COM_value); //print to the console for testing | |
//LED #`1 | |
if( COM_value == 1 ) { | |
digitalWrite( LED_one, HIGH ); // HIGH VOLTAGE - TURNED ON | |
} | |
if( COM_value == 2 ) { | |
digitalWrite( LED_one, LOW ); // LOW VOLTAGE - TURNED OFF | |
} | |
//LED #2 | |
if( COM_value == 3 ) { | |
digitalWrite( LED_two, HIGH ); | |
} | |
if( COM_value == 4 ) { | |
digitalWrite( LED_two, LOW ); | |
} | |
//LED #3 | |
if( COM_value == 5 ) { | |
digitalWrite( LED_three, HIGH ); | |
} | |
if( COM_value == 6 ) { | |
digitalWrite( LED_three, LOW ); | |
} | |
//LED #4 | |
if( COM_value == 7 ) { | |
digitalWrite( LED_four, HIGH ); | |
} | |
if( COM_value == 8 ) { | |
digitalWrite( LED_four, LOW ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment