From 469bb2accf96dbb5dbb61c4edd850e0b8cbfd919 Mon Sep 17 00:00:00 2001 From: Harshikerfuffle Date: Tue, 16 Apr 2019 14:48:21 -0400 Subject: [PATCH] Create T_Strip_Ardu.ino --- Triangle_Strip/T_Strip_Ardu.ino | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Triangle_Strip/T_Strip_Ardu.ino diff --git a/Triangle_Strip/T_Strip_Ardu.ino b/Triangle_Strip/T_Strip_Ardu.ino new file mode 100644 index 0000000..225acd1 --- /dev/null +++ b/Triangle_Strip/T_Strip_Ardu.ino @@ -0,0 +1,40 @@ +//For ARDUINO + +int ledPin = 7; +int potPin = A0; +int photoPin = A1; +int potOutput; +int photoReading; + +void setup() { + pinMode(ledPin, OUTPUT); + Serial.begin(9600); +} + +void loop() { + potOutput = analogRead(potPin); + photoReading = analogRead (photoPin); +// Serial.println(photoReading); + + int mappedOutput = map(potOutput, 0, 1023, 0, 255); //map the output +// int mappedOutputB = map(photoReading, 0, 1023, 0, 255); + + Serial.println(mappedOutput); +// Serial.println(mappedOutputB); + +// Serial.write(mappedOutput); + + if (Serial.available ( ) > 0) { // Checking if the Processing IDE has send a value or not + char state = Serial.read ( ); // Reading the data received and saving in the state variable + + if (state == '1') { // If received data is '1', then turn on LED + digitalWrite (ledPin, HIGH); + } + + if (state == '0') { // If received data is '0', then turn off led + digitalWrite (ledPin, LOW); + } + } + + delay(50); +}