Skills Dev 2- Amal

Made by Amal Jafrani

Created: November 11th, 2021

0

Outcome

The goal of this skills dev was to create a circuit using sensors and one output. I decided to use a switch and a photoresistor, so that I would work with a sensor with multiple values and then a sensor with two values. The led turns on based on the switch, but the photoresistor determines the brightness of the LED. Images are uploaded to canvas.

0
int led1 = D2;
int sensor = A0;
int tiltSwitch = D3;



void setup() {

pinMode(led1, OUTPUT);
pinMode(tiltSwitch, INPUT);
Serial.begin(9600);

}

void loop() {
    
    int switchRead = digitalRead(tiltSwitch);
    int val = analogRead(sensor);
    int brightness = map(val, 0, 4095, 0, 255);
    
    if (switchRead == HIGH){
        analogWrite(led1, brightness);
        Serial.print(brightness);
        
    }
    else {
        digitalWrite(led1, LOW);
    }

}
Click to Expand
0

Process

I attempted to do this by first working with the tilt switch to make sure the led was turning on and off based on the switch, and then the next step was introducing the photoresistor. I did not have a difficult time with the circuit or code, but it is taking me time to get used to particle. I wanted to see what values the sensor was outputting based on how much I was covering it, but was having a difficult time figuring out Serial,print and how to view it.

0

Reflection

I think I took a fairly simple approach to this skills dev, so if I had more time I would want to experiment more with other sensors and think more deeply about how I could make the interaction more exciting. I would also want to think of more creative ways to incorporate the sensors.

x