Stap 4: Code
De arduino IDE gebruiken voor het uploaden van de code aan de Raad, u wilt wijzigen de IDE te maken ondersteunen de Linkit één bestuur. Ook uw netwerk-ssid en wachtwoord invoeren.
int LDR = A0; //analog pin to which LDR is connected, here we set it to 0 so it means A0int LDRValue = 0; //that’s a variable to store LDR values int light_sensitivity = 500; //This is the approx value of light surrounding your LDR void setup() { Serial.begin(9600); //start the serial monitor with 9600 buad pinMode(13, OUTPUT); //we mostly use 13 because there is already a built in yellow LED in arduino which shows output when 13 pin is enabled } void loop() { LDRValue = analogRead(LDR); //reads the ldr’s value through LDR Serial.println(LDRValue); //prints the LDR values to serial monitor delay(50); //This is the speed by which LDR sends value to arduino if (LDRValue < light_sensitivity) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); } }