Commit d3862d20 authored by harry.sawdon's avatar harry.sawdon

Source code final

parents
#include <Wire.h>
#include "rgb_lcd.h"
#include <WiFiNINA.h>
#include "ThingSpeak.h"
rgb_lcd lcd;
const int pinLight = A0;
bool brightness()
{
return (analogRead(pinLight)<80);
}
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0, 0);
char ssid[] = "AndroidAP";
char password[] = "crer0439";
int status = WL_IDLE_STATUS;
Serial.begin(9600);
status = WiFi.begin(ssid, password);
if(status != WL_CONNECTED){
lcd.println("Failed");
while (true);
}
else{
lcd.println(WiFi.localIP());
}
pinMode(3, OUTPUT);
}
void loop(){
const unsigned long channel_id = 1996098;
const char write_api_key[] = "U5ME119V07YLVSTG";
WiFiClient client;
ThingSpeak.begin(client);
while(true){
int value = analogRead(A0);
lcd.setCursor(9, 1);
lcd.print(value);
; ThingSpeak.setField(1, int(value));
ThingSpeak.writeFields(channel_id, write_api_key);
if(!brightness())
{
digitalWrite(3, HIGH);
delay(1000);
digitalWrite(3, LOW);
delay(1000);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment