Assignment 11.1

Post date: Aug 02, 2010 9:33:18 PM

I turned this:

into this:

To get these:

So I could do this:

(The tiny incandescent light was already attached to the motor as the "headlight" of the motorcycle, so I just left it on there. Also the thing jumping around is quite obviously the motor.)


const int switch1 = 4; // Digital pin 6 connected to the push button

const int transistor1 = 9; // connected to the base of the transistor

void setup() {

// set the transistor pin as output:

pinMode(transistor1, OUTPUT);


void loop() {

// turn the motor on or off based on the state of the push button

digitalWrite(transistor1, digitalRead(switch1));


(Quick note the I used a 4 battery pack, not 2. Fritzing just didn't have a part for it and I didn't exactly find it necessary to make a new part just for the sake of adding 2 batteries.)