My drawing machine consists of a remote controlled car, a constructed wooden holder for two markers, and a potentiometer switch.
By soldering connections to the switches on the back of the chip in the remote control, I was able to program movements for the car. I had some issues in the beginning because the switches on the remote were activated by ground connections so at first I thought I wouldn’t be able to use the remote to activate each function separately.
Instead, I attempted to control the car’s motors directly with the arduino. The 6v DC motor was too much of a draw on the arduino. Also, the small dc motor I was spinning the markers with didn’t have enough torque to really turn the markers on a surface or be run off of the arduino with the other connections. I separated that component as optional and put an SPDT switch on it that directly connected it to the car battery’s power. I was able to get the smaller motor that just turned the wheels of the car to work in my programmed sequence.
I abandoned this strategy when I realized I wouldn’t be able to control the motors without an external power supply along with issues soldering the chip on the car.
My second attempt with the wireless remote was successful. Through various combinations of HIGH and LOW voltage between the leads I soldered to the switches, I was able to get the correct reactions I wanted from the car. I also added a potentiometer switch to turn it on and off from the remote/arduino and not have to chase down the car.
Overall, the project wasn’t exactly what I originally envisioned but it made me learn a LOT about motors and their requirements and I had a really involved exploration on getting the triggering for the switches right.
Here’s the code I wrote:
const int leftPin = 9;
const int rightPin = 8;
const int forwardPin = 7;
const int backwardPin = 6;
const int sensorPin = A0; //potentiometer to turn the machine on or off
void setup() {
pinMode(rightPin, OUTPUT);
pinMode(forwardPin, OUTPUT);
pinMode(leftPin, OUTPUT);
pinMode(backwardPin, OUTPUT);
}
void loop(){ //different combinations of HIGH and LOW for pins produced
//desired movements.
int sensorValue = 0;
int threshold = 512; // turn on if potentiometer is high
sensorValue = analogRead(sensorPin);
if(sensorValue > threshold){
digitalWrite(rightPin, LOW); //move forward with right turn
digitalWrite(leftPin, LOW);
digitalWrite(backwardPin, LOW);
digitalWrite(forwardPin, HIGH);
delay(130);
digitalWrite(backwardPin, HIGH); //pause or coast
digitalWrite(rightPin, HIGH);
delay(1500);
digitalWrite(rightPin, LOW); //move backward with left turn
digitalWrite(leftPin, HIGH);
digitalWrite(backwardPin, HIGH);
digitalWrite(forwardPin, LOW);
delay(150);
digitalWrite(backwardPin, HIGH); //pause or coast
digitalWrite(leftPin, HIGH);
digitalWrite(forwardPin, HIGH);
digitalWrite(rightPin, HIGH);
delay(1500);
}
else {
digitalWrite(rightPin, HIGH); //machine doesn’t move if potentiometer is low
}
}