Created
August 29, 2020 09:16
-
-
Save findtharun/d2efe3eec3998ab435a6506d1477d7a9 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
int a; | |
int voltage_A2 = A2; | |
int actualvoltage; | |
int voltage; | |
void setup() | |
{ | |
pinMode(8, OUTPUT); //LED 1 | |
pinMode (9, OUTPUT); //LED 2 | |
pinMode (10, OUTPUT); //LED 3 | |
pinMode (11, OUTPUT); //LED 4 | |
pinMode (12, OUTPUT); //LED 5 | |
pinMode (A2, INPUT); //DETECTOR | |
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps | |
while (! Serial); // Wait untilSerial is ready | |
Serial.println("Enter A To Start Take Reading"); | |
Serial.print (" 1 = 780nm"); | |
Serial.println(); | |
Serial.print (" 2 = 850nm"); | |
Serial.println(); | |
Serial.print (" 3 = 870nm"); | |
Serial.println(); | |
Serial.print (" 4 = 910nm"); | |
Serial.println(); | |
Serial.print (" 5 = 940nm"); | |
Serial.println();} | |
void loop() | |
{ | |
if (Serial.available()) | |
{ | |
char ch = Serial.read(); | |
if (ch == 'A') | |
for (a=0; a<5; a++) | |
{ | |
// LED 1 | |
digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(1000); // wait for a second | |
voltage = analogRead (A2); | |
Serial.print("LED1 :: "); | |
Serial.print (voltage); | |
Serial.print ("\t"); | |
digitalWrite(8, LOW); // turn the LED off by making the voltage LOW | |
//LED 2 | |
analogWrite (9, 255); //turn the LED on (voltage is High) | |
delay(1000); // wait for a second | |
voltage = analogRead (A2); | |
Serial.print("LED2 :: "); | |
Serial.print (voltage); | |
Serial.print ("\t"); | |
analogWrite(9, 0); // turn the LED off by making the voltage LOW | |
//LED 3 | |
analogWrite (10, 255); // TURN THE LED ON (VOLTAGE IS HIGH) | |
delay(1000); // wait for a second | |
voltage = analogRead (A2); | |
Serial.print("LED3 :: "); | |
Serial.print (voltage); | |
Serial.print ("\t"); | |
analogWrite(10, 0); // turn the LED off by making the voltage LOW | |
//LED 4 | |
analogWrite (11, 255); // TURN THE LED ON (VOLTAGE IS HIGH) | |
delay(1000); // wait for a second | |
voltage = analogRead (A2); | |
Serial.print("LED4 :: "); | |
Serial.print (voltage); | |
Serial.print ("\t"); | |
analogWrite(11, 0); // turn the LED off by making the voltage LOW | |
//LED 5 | |
digitalWrite (12, HIGH); // TURN THE LED ON (VOLTAGE IS HIGH) | |
delay(1000); // wait for a second | |
voltage = analogRead (A2); | |
Serial.print("LED5 :: "); | |
Serial.print (voltage); | |
Serial.print ("\t"); | |
digitalWrite(12, LOW); // turn the LED off by making the voltage LOW | |
Serial.println(); | |
// return; | |
//} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment