Today we learned how to use arduino. First we used a premade code to make an LED light up and then blink. Then we made a Servo move usinng a code given to us. Then we made a potentiometer work using a different code given to us. Then we were challenged to combine the servo and potentiometer code to make the two connected. Once we did that we were challenged to add an LED to the mix.
Here is the LED, Servo, and potentiometer combined code:
//data base for this servo
#include <Servo.h>
//servo is named Keziah
Servo Keziah;
//the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// Servo power comes from digital 6
Keziah.attach(6);
// LED power comes from digital 13
pinMode(13, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
int s = map(sensorValue,0,1023,0,180);
// printing value of s(0-180)
Serial.println(s);
// move the servo to angle s
Keziah.write(s);
// turn the LED on (HIGH is the voltage level)
digitalWrite(13, HIGH);
// wait for s amount of seconds
delay(s);
// turn the LED off by making the voltage LOW
digitalWrite(13, LOW);
// delayed by s amount of seconds
delay(s);
}
An Idea for the studio could be a prosthetic that helps with simple daily tasks