Assignment 7 – Sensor and Push Button

Concept

For this assignment I used two different LED lights one is switched on my a push button, and the other changes it’s brightness based on the lighting detected by the light sensor.

Code

int led = 11;

void setup(){
  Serial.begin(9600);
  pinMode(led,OUTPUT);
}

void loop(){
  int sensorValue = analogRead(A2);
  Serial.println(sensorValue);
  analogWrite(led,sensorValue/4);
  delay(50);
}

Github

Setup

The setup was drawn using Tinkercad

Schematic

The schematic was drawn using Tinkercad

Demonstration

Video

 

Leave a Reply