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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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);
}
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); }
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