I have an idea for making an simple robot. Maybe solar powered... doesnt have to be...
I have an ATTiny85, an h-bridge from an arduino motorshield (L293D, I think) and some LDR sensors and some 3V-6V motors.
My question is, can I somehow put them all together to make a simple robot? If so, do I need anything else, besides simple resistors and capacitors? Or am I missing something?
Update 3-25-2012: So I used this simple code to program the ATtiny using the Arduino as ISP
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
}
void loop() {
digitalWrite(0, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(0, LOW); // set the LED off
delay(1000); // wait for a second
digitalWrite(1, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(1, LOW); // set the LED on
delay(1000); // wait for a second
}
Here is a picture of my circuit
Check out the video! I got the motor to turn both directions. Forward and reverse!
Update 2 - 3-25-2012 : I added a LDR sensor to the circuit and updated the code to turn the motor forward if the analog reads less than 500 and opposite if it read more than 500.
int photocellPin = 2; // the cell and 10K pulldown are connected to a0
int photocellReading; // the analog reading from the sensor divider
void setup() {
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
digitalWrite(0, LOW);
digitalWrite(1, LOW);
}
void loop() {
photocellReading = analogRead(photocellPin);
if (photocellReading < 500){
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
}
if (photocellReading > 500) {
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
}
delay(150);
}
https://www.youtube.com/watch?v=1BYs6fu32_c