Questions
- My partner and I intended to assemble a circuit that used moisture as the trigger to light up a LED. We made it so that the LED would only light up after there was a certain amount of moisture present. That threshold of moisture was adjustable in our code. Our creation is pragmatic for example in buildings that are prone to flooding. When the sensors detect water they could automatically light up emergency lights to aid vision, or even power other objects like maybe a speaker.
- The reason why code is often compared to following a tutorial is because you must follow the order. In functional code, you must go through the steps to get to the end product. For example, you must first declare your variables first before you use them, and same with your methods. Writing coding follows a timeline of steps.
- The computer has definitively influenced our behaviors. Humans are creatures of mistakes, while computers are creatures of logic and perfection. Humans make mistakes, computers do not. When a computer makes a mistake it can always be traced back to humans. This idea of the computer has changed the behaviors of humans because now we depend on them. For example, with the invention of the computer it completely invalidates the typewriter. With the typewriter, if you made a mistake it would be extremely hard to undo that, but not on a computer. Computers have allowed humans to store mass amounts of data, so there is no more need to write everything down. The computer has made everything easier, and humans reliant on them.
Materials/Diagram
1 * Arduino Uno
1 * USB A to B cable
1 * breadboard
1 * LED
1* 220 ohm resistors
1*Moisture Sensor
A handful of jumper cables
Drawing drawn by my Partner: Jennifer Cheung
Task
For this recitation’s exercise, please work with a partner. Choose one of the sensors listed below and read about what it is and how it performs. Once you have picked a sensor, build a circuit that integrates this sensor with your Arduino. Use the data (input) from your sensor to drive an output (Servo-motor, LEDs, Buzzer, etc.). Document the finished circuit and your interaction with it.
As you can see from the video below, our finished product was successful. The moisture sensor was easy to assemble because we learned how to assemble a servitor in class. After completing the circuit we begin to write the code, and after putting in a simple if/else we uploaded our code and tried to get the LED to light up. The serial monitor was sensing the moisture, but our LED was not working. Eventually we figured out the only problem was the polarity of the LED, and after we got that sorted out everything worked perfectly. The code is also attached below.
int sensorPin = A0;
int sensorValue = 0;
int ledPin = 9;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.print(“Moisture = ” );
Serial.println(sensorValue);
delay(100);
if(sensorValue > 100)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}