Had the urge to draw last night so I drew what I saw. On the headboard of my bed there is a little plushy frog that has magnets in his feet so he can hug things. I got him for Christmas many many years ago and ever since I got this bed he has hugged the bars and watched over my at night. So I decided to draw him. It's not very good but i figure if i keep drawing what I see eventually I will draw something worth seeing.
~(' ')~
Wednesday, 28 December 2011
Tuesday, 27 December 2011
Knight Rider
So for my birthday one of my friends got me a soldering iron so I was finally able to dismantle a bunch of LEDs that Talia had given to by several months ago. The fun part was that this gave me enough LEDs to do my next electronics project. It was another fairly simple project that just turned on one of 10 leds in a row producing an effect similar to the one for the knightrider car KITT (yes, I'm that old).
Code:
int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int currentLED = 0;
int dir = 1;
int ledDelay = 65;
void setup()
{
for(currentLED = 0; currentLED < 10; currentLED++)
{
pinMode(ledPins[currentLED], OUTPUT);
}
currentLED = 0;
}
void loop()
{
digitalWrite(ledPins[currentLED], HIGH);
delay(ledDelay);
digitalWrite(ledPins[currentLED], LOW);
currentLED = currentLED + dir;
if(currentLED == 9)
{
dir = -1;
}
if(currentLED == 0)
{
dir = 1;
}
}
Code:
int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int currentLED = 0;
int dir = 1;
int ledDelay = 65;
void setup()
{
for(currentLED = 0; currentLED < 10; currentLED++)
{
pinMode(ledPins[currentLED], OUTPUT);
}
currentLED = 0;
}
void loop()
{
digitalWrite(ledPins[currentLED], HIGH);
delay(ledDelay);
digitalWrite(ledPins[currentLED], LOW);
currentLED = currentLED + dir;
if(currentLED == 9)
{
dir = -1;
}
if(currentLED == 0)
{
dir = 1;
}
}
Nothings really that complicated. Used an array to save all the pin numbers, and an index to point to the current led. Sadly I didn't have enough wires to connect things properly (I really need to get some wire strippers and a big spool of solid core wire) so I improvised a little with the ground wires :)
~(' ')~
Sunday, 18 December 2011
Dash Dash Dash Dot Dot Dot Dash Dash Dash....
So I was reading through a new arduino book (Beginning Arduino by Michael McRoberts) that I found online through my school library and the second project they talk about is an SOS morse code blinking LED. Pretty simple. I'm not a huge fan of simple, I like interesting times. So I decided to skip what the book wanted me to do and make my own general morse code blinker.
First, the circuit. Its pretty simple, just an LED connected to pin 2 of the arduino, it has a 220 ohm resister to protect the led.
The fun part was the code. I wanted it to be able to display any message typed into the computer. So first I defined what a dash and a dot are. Thank you Wikipedia :) Then its some quick and dirty letter conversions and a loop to read in data from the serial port and we are off
Code:
/**
* Author: John Stemberger
* Date: December 18, 2011
* Description: A morse code blinker. This will blink a sentence in Morse code. The sentence will either be the defualt sentence (SOS) or a sentence read in from the serial connection if one exists
**/
char sentence[255] = "SOS\0";
int ledPin = 2;
int counter = 0;
int dotLength = 100;
void setup()
{
// set up the pin
pinMode(ledPin, OUTPUT);
// setup serial connection to the computer to read the sentence
Serial.begin(9600);
}
void dot()
{
Serial.print("DOT ");
digitalWrite(ledPin, HIGH);
delay(dotLength);
digitalWrite(ledPin, LOW);
delay(dotLength);
}
void dash()
{
Serial.print("DASH ");
digitalWrite(ledPin, HIGH);
delay(3*dotLength);
digitalWrite(ledPin, LOW);
delay(dotLength);
}
void displayLetter(char letter)
{
// 1. a dash is equal to 3 dots
// 2. the space between parts of the same letter is eual to one dot
// 3. the space between two letters is equal to three dots
// 4. the space between 2 words is equal to 7 dots
switch(letter)
{
case 'A':
dot();
dash();
break;
case 'B':
break;
case 'C':
dash();
dot();
dash();
dot();
break;
case 'D':
dash();
dot();
dot();
break;
case 'E':
dot();
break;
case 'F':
dot();
dot();
dash();
dot();
break;
case 'G':
dash();
dash();
dot();
break;
case 'H':
dot();
dot();
dot();
dot();
break;
case 'I':
dot();
dot();
break;
case 'J':
dot();
dash();
dash();
dash();
break;
case 'K':
dash();
dot();
dash();
break;
case 'L':
dot();
dash();
dot();
dot();
break;
case 'M':
dash();
dash();
break;
case 'N':
dash();
dot();
break;
case 'O':
dash();
dash();
dash();
break;
case 'P':
dot();
dash();
dash();
dot();
break;
case 'Q':
dash();
dash();
dot();
dash();
break;
case 'R':
dot();
dash();
dot();
break;
case 'S':
dot();
dot();
dot();
break;
case 'T':
dash();
break;
case 'U':
dot();
dot();
dash();
break;
case 'V':
dot();
dot();
dot();
dash();
break;
case 'W':
dot();
dash();
dash();
break;
case 'X':
dash();
dot();
dot();
dash();
break;
case 'Y':
dash();
dot();
dash();
dash();
break;
case 'Z':
dash();
dash();
dot();
dot();
break;
case ' ':
// spaces will have 3 dots before it, and 2 dots after (from the pervious letter and the end of this letter) so the space will need 2
extra dots to make a total of 7
delay(2*dotLength);
break;
default:
Serial.print("unknown letter [");
Serial.print(letter);
Serial.println("]");
}
delay(2*dotLength);// the space between letters is 3 dots but the end of the last part of the letter will have a 1 dot delay (to finish that letter) so
e only do 2 dots here.
}
void loop()
{
if(Serial.available())
{
counter = 0;
while(Serial.available())
{
// get the new sentence
sentence[counter] = Serial.read();
if(sentence[counter] >= 'a' && sentence[counter] <= 'z')
{
sentence[counter] = sentence[counter] - 'a' + 'A';
}
if((sentence[counter] < 'A' || sentence[counter] > 'Z') && sentence[counter] != ' ')
{
Serial.println('non valid letter, replacing with space');
sentence[counter] = ' ';
}
counter++;
if(counter > 254)
{
// we have hit the limit of our sentence so abport
Serial.println("Sentence is too long, ignoring the rest.");
break;
}
}// end while we have available data on the serial port
sentence[counter] = '\0';
Serial.flush();
}// end if
// if there is nothing available (we havent gotten anything) then display the currect message
// echo it out to the serial port
Serial.print("Displaying code for: ");
Serial.println(sentence);
counter = 0;
while(sentence[counter] != '\0')
{
Serial.print(sentence[counter]);
Serial.print("- ");
displayLetter(sentence[counter]);
counter++;
}
Serial.println("\nEnd message");
delay(500);
}
First, the circuit. Its pretty simple, just an LED connected to pin 2 of the arduino, it has a 220 ohm resister to protect the led.
The fun part was the code. I wanted it to be able to display any message typed into the computer. So first I defined what a dash and a dot are. Thank you Wikipedia :) Then its some quick and dirty letter conversions and a loop to read in data from the serial port and we are off
Code:
/**
* Author: John Stemberger
* Date: December 18, 2011
* Description: A morse code blinker. This will blink a sentence in Morse code. The sentence will either be the defualt sentence (SOS) or a sentence read in from the serial connection if one exists
**/
char sentence[255] = "SOS\0";
int ledPin = 2;
int counter = 0;
int dotLength = 100;
void setup()
{
// set up the pin
pinMode(ledPin, OUTPUT);
// setup serial connection to the computer to read the sentence
Serial.begin(9600);
}
void dot()
{
Serial.print("DOT ");
digitalWrite(ledPin, HIGH);
delay(dotLength);
digitalWrite(ledPin, LOW);
delay(dotLength);
}
void dash()
{
Serial.print("DASH ");
digitalWrite(ledPin, HIGH);
delay(3*dotLength);
digitalWrite(ledPin, LOW);
delay(dotLength);
}
void displayLetter(char letter)
{
// 1. a dash is equal to 3 dots
// 2. the space between parts of the same letter is eual to one dot
// 3. the space between two letters is equal to three dots
// 4. the space between 2 words is equal to 7 dots
switch(letter)
{
case 'A':
dot();
dash();
break;
case 'B':
break;
case 'C':
dash();
dot();
dash();
dot();
break;
case 'D':
dash();
dot();
dot();
break;
case 'E':
dot();
break;
case 'F':
dot();
dot();
dash();
dot();
break;
case 'G':
dash();
dash();
dot();
break;
case 'H':
dot();
dot();
dot();
dot();
break;
case 'I':
dot();
dot();
break;
case 'J':
dot();
dash();
dash();
dash();
break;
case 'K':
dash();
dot();
dash();
break;
case 'L':
dot();
dash();
dot();
dot();
break;
case 'M':
dash();
dash();
break;
case 'N':
dash();
dot();
break;
case 'O':
dash();
dash();
dash();
break;
case 'P':
dot();
dash();
dash();
dot();
break;
case 'Q':
dash();
dash();
dot();
dash();
break;
case 'R':
dot();
dash();
dot();
break;
case 'S':
dot();
dot();
dot();
break;
case 'T':
dash();
break;
case 'U':
dot();
dot();
dash();
break;
case 'V':
dot();
dot();
dot();
dash();
break;
case 'W':
dot();
dash();
dash();
break;
case 'X':
dash();
dot();
dot();
dash();
break;
case 'Y':
dash();
dot();
dash();
dash();
break;
case 'Z':
dash();
dash();
dot();
dot();
break;
case ' ':
// spaces will have 3 dots before it, and 2 dots after (from the pervious letter and the end of this letter) so the space will need 2
extra dots to make a total of 7
delay(2*dotLength);
break;
default:
Serial.print("unknown letter [");
Serial.print(letter);
Serial.println("]");
}
delay(2*dotLength);// the space between letters is 3 dots but the end of the last part of the letter will have a 1 dot delay (to finish that letter) so
e only do 2 dots here.
}
void loop()
{
if(Serial.available())
{
counter = 0;
while(Serial.available())
{
// get the new sentence
sentence[counter] = Serial.read();
if(sentence[counter] >= 'a' && sentence[counter] <= 'z')
{
sentence[counter] = sentence[counter] - 'a' + 'A';
}
if((sentence[counter] < 'A' || sentence[counter] > 'Z') && sentence[counter] != ' ')
{
Serial.println('non valid letter, replacing with space');
sentence[counter] = ' ';
}
counter++;
if(counter > 254)
{
// we have hit the limit of our sentence so abport
Serial.println("Sentence is too long, ignoring the rest.");
break;
}
}// end while we have available data on the serial port
sentence[counter] = '\0';
Serial.flush();
}// end if
// if there is nothing available (we havent gotten anything) then display the currect message
// echo it out to the serial port
Serial.print("Displaying code for: ");
Serial.println(sentence);
counter = 0;
while(sentence[counter] != '\0')
{
Serial.print(sentence[counter]);
Serial.print("- ");
displayLetter(sentence[counter]);
counter++;
}
Serial.println("\nEnd message");
delay(500);
}
~(' ')~
pizza pizza
So last night Talia requested some pizza and I was more than willing to provide. Until last night pizza has always been a several hour endeavour because we always made small personal pizzas which each take 15 minutes to cook and even longer to decorate so I wasn't really feeling like that much work. I also had a new recipe for pizza dough that I wanted to try out so I was excited. This recipe is almost the same as the old one except I add 4 Tbsp of olive oil to flavour the dough and I let to prove for an hour. Also, there was no added sugar because the yeast had time to prove the dough.
When I rolled out the pizza dough it was much bigger than the pizza pan I had so decided to make it a cheese stuffed crust pizza
In total the dough recipe made 2 full pizzas, a calzone and I have dough in the fridge for 1 more full pizza :)
Sunday, 11 December 2011
Reduce, Recycle, and of course.... REUSE!!!!!!
So I spent the better part of this morning carefully taking Talias old laptop apart to see if I could salvage any parts. Her laptop died a while ago (the graphics card melted) and she has wanted to take it apart for a while.
So I kept all of the pieces and screws, now I just have to figure out how to connect to all of these pieces. As an example of the times of pieces I salvages...
I'm going to slowly try and map out what all the pins are. I think I know which are the ground wires (there are 3 from what I can tell) and the LED wires, but I'm not 100% sure about them. I cant seem to find which cables are connected to the buttons but part of the problem is that my multimeter broke so I have to go and get it fixed before I can do much more :(
P.S. the LEDs are all blue
So I kept all of the pieces and screws, now I just have to figure out how to connect to all of these pieces. As an example of the times of pieces I salvages...
Wireless card. the black/white are where the antenna cables connect. You will see them in a bit
The bluetooth card. Cause everything is better with bluetooth
The monitor and several of the cables. The thick one is the monitor cable, I forget what the one above that is, but the top most cable is the antenna for the wireless
The power button circuit board. This is the smallest and simplest part so it is what I am going to be starting with.It has 12 cables, 7 LEDs, and 2 Buttons (a black and a grey one)
I'm going to slowly try and map out what all the pins are. I think I know which are the ground wires (there are 3 from what I can tell) and the LED wires, but I'm not 100% sure about them. I cant seem to find which cables are connected to the buttons but part of the problem is that my multimeter broke so I have to go and get it fixed before I can do much more :(
P.S. the LEDs are all blue
Saturday, 10 December 2011
Motor 1
So the other day I went out and bought a a couple of motors and servos to play with. Unfortunately I didn't have much time to play so today is the first day I got to.
I started off wanting to connect the motor to and h-bridge to let me run it in both directions but to do that I am told I need a capacitor and a diode which I unfortunately don't have. But I did have a transistor (NPN) so I could turn it on and off. To isolate the motor from the arduino I used an external power plug that is rated at 4.5V but when I tested it ran at 6.6V. The motor I got is actually a 12V motor but again, when I tested it the motor ran fine, if a little slow. So I wired everything up and found that I got.... NOTHING :(
So I started looking into why it wasn't working and it turns out that the transistor is chewing up too much voltage to run the motor (I think). When I measured the voltage coming out of the transistor it was only 3.3V. I'm not 100% sure about this because I also went and connected the power directly to the motor but with the multimeter in serial to the motor. It measured 6.6V but the motor still wouldn't run. So maybe its an amperage problem? I don't have any specifications on how much amperage the motor requires to run :(
~(' ')~
I started off wanting to connect the motor to and h-bridge to let me run it in both directions but to do that I am told I need a capacitor and a diode which I unfortunately don't have. But I did have a transistor (NPN) so I could turn it on and off. To isolate the motor from the arduino I used an external power plug that is rated at 4.5V but when I tested it ran at 6.6V. The motor I got is actually a 12V motor but again, when I tested it the motor ran fine, if a little slow. So I wired everything up and found that I got.... NOTHING :(
~(' ')~
Thursday, 1 December 2011
Zap Zap
So I have been drooling over this open source micro controller called the arduino for 2 weeks, and last night I finally went out with talia and got one :) along with a whole bunch of goodies like LEDs, resistors, and transisters
I spent a good 2 hours playing around with it and getting some LEDs to turn on and pulse and stuff.
First I simply wrote a piece of code to turn on the on-board LED every second for 1 second, then turn it off for 2 seconds
Code:
// this will be the pin for the onboard led :)
int ledPin1 = 13;
void setup()
{
pinMode(ledPin1, OUTPUT);
}
void loop()
{
digitalWrite(ledPin1, HIGH); // turn the led on
delay(1000); // wait for 1S
digitalWrite(ledPin1, LOW); // turn the led off
delay(2000); // wait for 2S
}
Then I plugged in an external LED into the same pin as the on-board LED and watched it blink along with the on-board LED (no pics, sorry)
Then I wanted to plug a whole bunch of LEDs into a breadboard and blink them using a different pin than the on-board LED. This required the addition of a resister. In this test I had 3 LEDs, the first is connected to the on-board LED and the other two are connected to 2 other pins using resisters. I wanted to explore what the difference would be with different resisters so I had 1 LED connected in series with a 470 ohm resister and the other with a 4.7k resister
Code:
// this will be the pin for the onboard led :)
int ledPin1 = 13;
int LEDPin2 = 2;// this will be the led with a 470 ohm resister
int LEDPin3 = 4;// this will be the led with a 4.7k ohm resister
void setup()
{
// set the onboard led pin to an output pin
pinMode(ledPin1, OUTPUT);
pinMode(LEDPin2, OUTPUT);
pinMode(LEDPin3, OUTPUT);
}
void loop()
{
digitalWrite(ledPin1, HIGH); // turn the led on
// I want the new resister leds to blink out of phase with the onboard LED
digitalWrite(LEDPin2, LOW); // turn the led on
digitalWrite(LEDPin3, LOW); // turn the led on
delay(1000); // wait for 1S
digitalWrite(ledPin1, LOW); // turn the led off
digitalWrite(LEDPin2, HIGH); // turn the led on
digitalWrite(LEDPin3, HIGH); // turn the led on
delay(2000); // wait for 2S
}
The final thing I wanted to do was have an LED pulse its brightness. I did that using a pulse width modulated digital pin which alters its voltage based on the the value you give it.
code:
int PMWLEDPin = 3;
void setup()
{
pinMode(PMWLEDPin, OUTPUT);
}
void loop()
{
for(int i = 0;i <= 255; i = i + 10)
{
analogWrite(PMWLEDPin, i); // turn the led on
delay(10);
}
for(int i = 255;i >= 0; i = i - 10)
{
analogWrite(PMWLEDPin, i); // turn the led on
delay(10);
}
analogWrite(PMWLEDPin, 0);
delay(100);
}
I don't have pictures for that last one but it worked very nicely.
One of the things that I have noticed is that I have forgotten a LOT of my high school physics so I have to go and review all of that. If anyone can recommend a good webpage that goes over all of that basic stuff I would really appreciate it :)
As for the future, I have a couple projects in mind. I think I'm going to try and build a sentry gun from team fortress 2 :)
~(' ')~
I spent a good 2 hours playing around with it and getting some LEDs to turn on and pulse and stuff.
First I simply wrote a piece of code to turn on the on-board LED every second for 1 second, then turn it off for 2 seconds
Code:
// this will be the pin for the onboard led :)
int ledPin1 = 13;
void setup()
{
pinMode(ledPin1, OUTPUT);
}
void loop()
{
digitalWrite(ledPin1, HIGH); // turn the led on
delay(1000); // wait for 1S
digitalWrite(ledPin1, LOW); // turn the led off
delay(2000); // wait for 2S
}
Then I plugged in an external LED into the same pin as the on-board LED and watched it blink along with the on-board LED (no pics, sorry)
Then I wanted to plug a whole bunch of LEDs into a breadboard and blink them using a different pin than the on-board LED. This required the addition of a resister. In this test I had 3 LEDs, the first is connected to the on-board LED and the other two are connected to 2 other pins using resisters. I wanted to explore what the difference would be with different resisters so I had 1 LED connected in series with a 470 ohm resister and the other with a 4.7k resister
Code:
// this will be the pin for the onboard led :)
int ledPin1 = 13;
int LEDPin2 = 2;// this will be the led with a 470 ohm resister
int LEDPin3 = 4;// this will be the led with a 4.7k ohm resister
void setup()
{
// set the onboard led pin to an output pin
pinMode(ledPin1, OUTPUT);
pinMode(LEDPin2, OUTPUT);
pinMode(LEDPin3, OUTPUT);
}
void loop()
{
digitalWrite(ledPin1, HIGH); // turn the led on
// I want the new resister leds to blink out of phase with the onboard LED
digitalWrite(LEDPin2, LOW); // turn the led on
digitalWrite(LEDPin3, LOW); // turn the led on
delay(1000); // wait for 1S
digitalWrite(ledPin1, LOW); // turn the led off
digitalWrite(LEDPin2, HIGH); // turn the led on
digitalWrite(LEDPin3, HIGH); // turn the led on
delay(2000); // wait for 2S
}
The final thing I wanted to do was have an LED pulse its brightness. I did that using a pulse width modulated digital pin which alters its voltage based on the the value you give it.
code:
int PMWLEDPin = 3;
void setup()
{
pinMode(PMWLEDPin, OUTPUT);
}
void loop()
{
for(int i = 0;i <= 255; i = i + 10)
{
analogWrite(PMWLEDPin, i); // turn the led on
delay(10);
}
for(int i = 255;i >= 0; i = i - 10)
{
analogWrite(PMWLEDPin, i); // turn the led on
delay(10);
}
analogWrite(PMWLEDPin, 0);
delay(100);
}
I don't have pictures for that last one but it worked very nicely.
One of the things that I have noticed is that I have forgotten a LOT of my high school physics so I have to go and review all of that. If anyone can recommend a good webpage that goes over all of that basic stuff I would really appreciate it :)
As for the future, I have a couple projects in mind. I think I'm going to try and build a sentry gun from team fortress 2 :)
~(' ')~
Subscribe to:
Comments (Atom)














