Converting Pseudocode
int lightPin = A0; //define a pin for Photo resistor (input) int ledPin = 13; // the pin for the led (output) void setup() { Serial.begin(9600); //Begin serial communication pinMode( lightPin, INPUT ); pinMode( ledPin, OUTPUT ); } void loop() { int lightValue = analogRead( lightPin ); Serial.println( lightValue ); //Write the value of the photoresistor to the serial monitor. // if there is not enough light if ( lightValue < 400 ){ // turn on the LED digitalWrite( ledPin, HIGH ); } else{ // otherwise, turn it off digitalWrite( ledPin, LOW ); } delay(10); //short delay for faster response to light }CommentsVariables Functions
If Statements For Loops