Pages: [1]   Go Down
Author Topic: Newbie in need of help  (Read 4970 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there, community.
I´m new to the arduino and plan to learn a lot. I´m not sure, wheter this is the right place to post my question (i couldn´t find games&play), and I do know that a lot of people might say: ask google, start learning from the scratch...
I´m willing to do this, but my first "big" project is kind of a quick need. Next sunday we have a big festival and we are building a lot of games for children to play. I found one interesting game that I want to build in a "wooden edition" but with the extension of an arduino and I do need help in programming and connecting (I do know basics). Here is how the game works.
In front of the kid is a hand with 5 fingers (yep, that´s right) in each finger are two rgb-leds or a couple of colored leds. When the game starts, there are two leds on each finger on and the kid has to grab hair-bands and has to put them the right way on it´s own hand. The colors are supposed to be random. For example, the thumbs has 2xleds on, one green, one blue. The kid has to put a green and a blue hair-band on it´s finger. Once all the hair bands are in the correct place, the kid touches the hand and a timer stops, giving out the time needed to fullfil the task. (for I don´t have a display, I´m looking for an alternativ). We have a arduino (uno & mega), a couple of leds. If anyone can help, I would really appreciate.
Thanks, Uli
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27069
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like variation on Simon game, google that.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 32
Posts: 1211
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No I do not see any memory component (isnt that what Simon Says is?)

here is what I have translated the description to Arduino task
On button push a random set of lights turn on. Timer starts.
On other button push timer stops (display...?)

It doesnt matter if the light is an RGB or seperate LEDs. You have 10 LEDs or so - simple direct driving - through a resistor - for each pin will do. The program will only be a handfuld of lines for the lights.

The timer is dead easy: note millis() at start button, subtract from millis() when stop. divide by 1000 and display. The display is your biggest challenge here - if nothing else use a laptop and a terminal emulator showing the serial out with a BIG font.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Msquare is right, this is exactly what we are trying to build.

int finger11 = 13; /* whereas n1 is the upper led */
int finger12 = 12; /* n2 is the lower led */
int finger21 = 11;
int finger22 = 10;
int finger31 = 9;
int finger32 = 8;
int finger41 = 7;
int finger42 = 6;
int finger51 = 5;
int finger52 = 4;
int timer = 3;
void setup() {               
pinMode(led, OUTPUT);   
}
void loop() {
random.color for finger 11 to 52
start.timer
stop.timer when key pressed and display time
start over when key is pressed again
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the attachment is an image, on how it is supposed to look like in the end
(sorry forgot one led on the second finger top from the right)


* 3089296-holz-hand-mit-schild.jpg (60.15 KB, 639x1203 - viewed 67 times.)
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 32
Posts: 1211
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Msquare is right, this is exactly what we are trying to build.
Happy to help - but what is the question? A programming issue? A wiring issue?

BTW - use the Preview button and the "#" button so you can work out how to show program code in your posts

OK here are some answers. Just like in Jeopardy - what is the question smiley  smiley-mr-green
Code:
pinMode(led, OUTPUT);
should be
Code:
pinMode(finger11, OUTPUT);
pinMode(finger12, OUTPUT);
  // :  and so on
But really you should use an array.

Buttons should be wired between the Arduino pin and Ground. The input pin (and it can be any except 13) is then initialised with
Code:
pinMode(startbutton, INPUT_PULLUP);

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot, indeed it´s a programming question, the wiring shouldn´t be a problem
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can someone help me out and tell me what is wrong with this code?  It's giving me a function-definition is not allowed here before { token   

// define pins to be used

int S1 = 2; //switch 1
int S2 = 3;
int S3 = 4;
int L1 = 5; // light 1
int L2 = 6;
int L3 = 7;
int B = 8; //buzzer


void setup() { // initialize the digital pins. // assume switches will wire from ground to input pins
pinMode(S1, INPUT_PULLUP);
pinMode(S2, INPUT_PULLUP);
pinMode(S3, INPUT_PULLUP);
pinMode(L1, OUTPUT); // leds wired from output pin to ground }
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(B, OUTPUT); // buzzer wired from output pin to ground }

void loop() { if (!digitalRead(S1)) { digitalWrite(L1,HIGH); // turn on lamp 1
digitalWrite(B,HIGH); // turn on buzzer
delay(500); // wait 2 seconds
digitalWrite(B,LOW); // turn off buffer
delay(5000); // wait 28 more seconds
digitalWrite(L1,LOW); // turn off lamp 1 }
if (!digitalRead(S2)) { digitalWrite(L2,HIGH); // turn on lamp 2
digitalWrite(B,HIGH); // turn on buzzer
delay(500); // wait 2 seconds
digitalWrite(B,LOW); // turn off buffer
delay(5000); // wait 28 more seconds
digitalWrite(L2,LOW); // turn off lamp 2 }
if (!digitalRead(S3)) { digitalWrite(L3,HIGH); // turn on lamp 3
digitalWrite(B,HIGH); // turn on buzzer
delay(500); // wait 2 seconds
digitalWrite(B,LOW); // turn off buffer
delay(5000); // wait 28 more seconds
digitalWrite(L3,LOW); // turn off lamp 3 } }
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 32
Posts: 1211
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I fixed it. You were missing a bunch of "}"  The first error message you had was due to the loop() started before a "}" closed the previous void setup() .

 Notice that the code here is in a nice seperate box, which makes reading it easier. Also note the indentation - the editor does it if you press ^T. Read the top post on how to post to get these details right.

I do not know if this is the logic you want. The code you supplied had some "}" inside comments (after a "//" on the same line) and thus do not count. I have just sprinkled "}" at the end until it compiled.
Code:
// define pins to be used

int S1 = 2; //switch 1
int S2 = 3;
int S3 = 4;
int L1 = 5; // light 1
int L2 = 6;
int L3 = 7;
int B = 8; //buzzer


void setup() { // initialize the digital pins. // assume switches will wire from ground to input pins
  pinMode(S1, INPUT_PULLUP);
  pinMode(S2, INPUT_PULLUP);
  pinMode(S3, INPUT_PULLUP);
  pinMode(L1, OUTPUT); // leds wired from output pin to ground
  pinMode(L2, OUTPUT);
  pinMode(L3, OUTPUT);
  pinMode(B, OUTPUT); // buzzer wired from output pin to ground
}

void loop() {
  if (!digitalRead(S1)) {
    digitalWrite(L1,HIGH); // turn on lamp 1
    digitalWrite(B,HIGH); // turn on buzzer
    delay(500); // wait 2 seconds
    digitalWrite(B,LOW); // turn off buffer
    delay(5000); // wait 28 more seconds
    digitalWrite(L1,LOW); // turn off lamp 1 }
    if (!digitalRead(S2)) {
      digitalWrite(L2,HIGH); // turn on lamp 2
      digitalWrite(B,HIGH); // turn on buzzer
      delay(500); // wait 2 seconds
      digitalWrite(B,LOW); // turn off buffer
      delay(5000); // wait 28 more seconds
      digitalWrite(L2,LOW); // turn off lamp 2 }
      if (!digitalRead(S3)) {
        digitalWrite(L3,HIGH); // turn on lamp 3
        digitalWrite(B,HIGH); // turn on buzzer
        delay(500); // wait 2 seconds
        digitalWrite(B,LOW); // turn off buffer
        delay(5000); // wait 28 more seconds
        digitalWrite(L3,LOW); // turn off lamp 3
      }
    }
  }
}

Also note that code like
Code:
delay(500) ; // wait 2 seconds
is very confusing. The code says half a second, the comment says 2 seconds. Which did you want?
Logged

Pages: [1]   Go Up
Jump to: