FINAL PROJECT: PHASE 2
PROTOTYPE:
So far I have established the essential interactions for my companion pet. I have a button, buzzer, LED and photoresistor. That is 2 inputs, with the final potential for many outputs. Instead of the button in the final version, I will be using a strip of tape to act as a capacitance switch so that one may actually "pet" the robot. I may possibly also use an RGB LED instead of just a white LED, but that will depend on if I can arrange the wires correctly.
Here is the prototype's current code:
int ledPin = 2;
int photocellInput = 0;
int soundPin = 9;
int button = 4;
void setup() {
Serial.begin(9600);
pinMode (button, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(soundPin, OUTPUT);
}
void loop() {
photocellInput = map(analogRead(0),0,1023,0,254);
if(photocellInput < 25){
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
int but;
but = digitalRead(button);
if (but == 1) {
digitalWrite(soundPin,1);
tone(soundPin, 10, 10);
}
else{
digitalWrite(soundPin,0);
}
Serial.println(photocellInput);
delay(10); //reading delay
}
So far I have established the essential interactions for my companion pet. I have a button, buzzer, LED and photoresistor. That is 2 inputs, with the final potential for many outputs. Instead of the button in the final version, I will be using a strip of tape to act as a capacitance switch so that one may actually "pet" the robot. I may possibly also use an RGB LED instead of just a white LED, but that will depend on if I can arrange the wires correctly.
Here is the prototype's current code:
int ledPin = 2;
int photocellInput = 0;
int soundPin = 9;
int button = 4;
void setup() {
Serial.begin(9600);
pinMode (button, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(soundPin, OUTPUT);
}
void loop() {
photocellInput = map(analogRead(0),0,1023,0,254);
if(photocellInput < 25){
digitalWrite(ledPin, HIGH);
}
else {
digitalWrite(ledPin, LOW);
}
int but;
but = digitalRead(button);
if (but == 1) {
digitalWrite(soundPin,1);
tone(soundPin, 10, 10);
}
else{
digitalWrite(soundPin,0);
}
Serial.println(photocellInput);
delay(10); //reading delay
}
Comments
Post a Comment