We learned how to take input from a sensor such as a light sensor and feed back a range of values. I used these values to control the brightness of an led.
Here I used the same programming code and pretty much the same breadboard setup to rig a pressure sensor to a light.
The great thing is that it doesn't even take a lot of code to run:
const int potPin = A0;
const int led = 3;
int potValue = 0;
int newValue = 0;
void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
potValue = analogRead(potPin);
newValue = map(potValue,0,1023,0,255);
analogWrite(led, newValue);
Serial.println(potValue);
No comments:
Post a Comment