I haven’t forgotten!

I am currently moving house and changing jobs, so my Arduino projects are currently on hold and packed up ready for the move.
I haven’t forgotten, just haven’t got the time at the moment unfortunately, probably will have in about a month’s time.

From my coffee stained desk: my first Arduino example code – Random LED and Button Hits

I’m a little bit relieved. I was going to say excited, but I think relieved is a better word – it’s actually taken me a great deal of time to make this Arduino code work the way I wanted it to, but hey, I’m learning how to code for the Arduino, so that’s fine right?!

I have successfully prototyped my first Arduino example code which randomly selects an LED which is then switched on, and waits for the corresponding button to be hit.

Now this is only the “simple” beginnings of my code, which I will now build upon. What will I create from this code? Time will tell :-)

And guess what?! You get to see my example Arduino code in a little video, but you’ll have to excuse the coffee stain rings!

I’m interested to see if anyone has a different way of achieving the same result and whether my example Arduino code is actually any good – please let me know if I am doing something wrong as well!
I should also say, I have some variables in there that don’t make much sense at the moment, but they are in there for some future plans.

int timer = 500;
int play = 1; // 1 = in game | 0 = game over
int selnum = 0; //0 = green | 1 = red
int sensorValue2; // button2
int sensorValue3;// button3

void setup() {
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop() {

while (play == 1) {

Serial.println(selnum);

timer = 500;

if (selnum == 0) {
digitalWrite(12, HIGH);
while (timer > 0) {
sensorValue2 = digitalRead(2);
if (sensorValue2 == HIGH){
digitalWrite(12, LOW);
timer = 0;
delay(1000);
}
selnum = random(0,2);
}
}

if (selnum == 1) {
digitalWrite(13, HIGH);
while (timer > 0) {
sensorValue3 = digitalRead(3);
if (sensorValue3 == HIGH){
digitalWrite(13, LOW);
timer = 0;
delay(1000);
}
selnum = random(0,2);
}
}
}

digitalWrite(12, LOW);
digitalWrite(13, LOW);

}

The beginnings of my first Arduino project

I have started developing an idea in my head for game which will be my first official Arduino project example once I have completed it.

And in order to do that, I have started prototyping parts of the game now, which I will eventually build upon to create the finished game.

So here is the Arduino code I have so far. It’s VERY simple I know, but the entire premise of my game is simple so that’s fine.

Random LED Arduino Example Code

void setup() {
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  int selnum;
}

void loop() {

  int selnum = random(0,2);
  if (selnum == 0) {
   digitalWrite(12, HIGH);
  }
  if (selnum == 1) {
   digitalWrite(13, HIGH);
  }
  delay(500);
  digitalWrite(12, LOW);
  digitalWrite(13, LOW);
}

Basically all it does it randomly light one of the two LEDs. Simple. I will build upon that later.

From the postman, the Arduino Duemilanove finally arrived

I am glad I waited out the delivery time for ordering my Arduino Duemilanove on eBay Hong Kong.

Alongside the Arduino Duemilnove came a number of goodies, as I listed in a previous post.

arduino duemilanove starter kit from ebay

arduino duemilanove starter kit from ebay

 

 

 

 

 

 

 

 

 

I loved the customs declaration “Microcontroller kit for student science project”

arduino duemilanove hong kong customs delaration

arduino duemilanove hong kong customs delaration

 

 

 

 

 

 

 

 

So now it’s time to get going on the Arduino beginner tutorials..

From my brain, courtesy of Bugsplat

I was reading Pete Keen’s Blugsplat blog, and his attempt at making a Quadrotor with the Arduino, and wondered, if you used the Ping))) ultrasonic sensor, could you create an autonomous hovering quadrotor?

That mind sound pretty boring, maybe I should elaborate..

Read more…

From Ebay with love..

I finally bit the bullet and ordered a kit from Ebay. Now I have to play the waiting game. Delivery can take up to two weeks, and the royal mail website is so helpful, the only tracking information I am told is my package is “on its way”. Great. Thanks. Anyway, the kit I plumped for eventually was this one.

Read more…

The Arduino Uno or Duemilanove – From one to the other

The Arduino Uno or Duemilanove, which should I buy?

I originally wondered if there were any important differences, and whether the Duemilanove would still be ok to use. I was tempted by the Arduino Duemilanove due to the price difference between it – the “old” model – and the new Arduino Uno and after doing some research (read: Google), “Which is better the Arduino Uno or Duemilanove“, I found a number of interesting reads, including this one. Read more…

Follow

Get every new post delivered to your Inbox.