const int led1 = 11;
const int led2 = 10;
unsigned long prevmillis1 = 0;
unsigned long prevmillis2 = 0;
unsigned long prevmillis3 = 0;
unsigned long prevmillis4 = 0;
const long interval1 = 1000;
const long interval2 = 300;
const long interval3 = 200;
const long interval4 = 100;
int ledstate = LOW;
int sensorvalue1 = 0;
void setup(){
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop (){
unsigned long presentmillis = millis();
if(presentmillis - prevmillis1 >= interval1 ){
prevmillis1 = presentmillis;
if(ledstate == LOW)
{
ledstate = HIGH;
}
else
{
ledstate = LOW;
}
digitalWrite(led1,ledstate);
}
if(presentmillis - prevmillis3 >= interval3)
{
prevmillis3 = presentmillis;
Serial.println(analogRead(A0));
}
if(presentmillis - prevmillis2 >= interval2)
{
prevmillis2 = presentmillis;
sensorvalue1 = analogRead(A0);
sensorvalue1 = map(sensorvalue1,0,1023,0,255);
}
if(presentmillis - prevmillis4 >= interval4)
{
prevmillis4 = presentmillis;
analogWrite(sensorvalue1, led2);
}
}