Input devices

Today we learned how to use input devices and code on arduino how to calibrate them and have them as influencers in our digfab lives. Using a buzzer, copper sensor to sense touch, a touch sensor library, and a motor, I am going to boild a touch enabled trash can lid that opens when button is touched and makes an r2d2 sound. FIrst things first download a library specifically the blue highlighted one. Library Next, you are going to include this code in your setup and pre setup: (#include CapacitiveSensor Sensor = CapacitiveSensor(7, 5); void setup() { Serial.begin(9600); pinMode(13, OUTPUT); // put your setup code here, to run once: }) It should look like this: intro Here is the physical setup for the new program that allows the trash can bot to sense pressure. At approximately 3.41 pounds the program will start and the wheels will revolve. Here is the a picture of the physical pressure sensor setup with the copper sticker and cardboard plates. intro Next, we are going to make an if/ else program stating that when the sensor value is greater than 800 or whatever you want the sensor value to be, a certain thing happens in this case my program is going to run a loop 1 time in which it will allow a motor to spin one direction for a few seconds. In order to get a better value you will have to use the [MAP](https://www.arduino.cc/reference/en/language/functions/math/map/) code1 int val; int read_high; int read_low; int diff; long int sum; int N_samples = 100; void setup() { pinMode(4, OUTPUT); pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(9, OUTPUT); pinMode(8, OUTPUT); pinMode(6, OUTPUT); pinMode(5, OUTPUT); Serial.begin(9600); } void loop() { sum = 0; for (int i = 0; i &lt; N_samples; i++) { digitalWrite(4, HIGH); read_high = analogRead(A0); delayMicroseconds(100); digitalWrite(4, LOW); read_low = analogRead(A0); diff = read_high - read_low; sum += diff; } //sum = map(sum, 19, 75, 0, 5); Serial.println(sum); if ( sum &gt;= 13000) { digitalWrite(13, HIGH); digitalWrite(12, HIGH); digitalWrite(9, LOW); digitalWrite(8, LOW); digitalWrite(6, HIGH); delay(10000); digitalWrite(13, LOW); digitalWrite(12, LOW); digitalWrite(9, HIGH); digitalWrite(8, HIGH); digitalWrite(6, HIGH); delay(10000); tone(9, sum); } else { digitalWrite(13, LOW); digitalWrite(12, LOW); digitalWrite(9, LOW); digitalWrite(8, LOW); } }</p> function to tune to you specs. Lastly, if you want an r2d2 sound simply add "tone(9, sum);" and plug a tone buzzer thingamajig into port 9 and gnd. Click to download my code!!