Go Down

Topic: >>>>>>> RACING PROJECT **NEED OF URGENT HELP** <<<<<<< (Read 5300 times) previous topic - next topic

najeff2

Code: [Select]

#include <CapacitiveSensor.h>

/*
* Racing
*
*  Run with your fingers as fast as you can.
*
* In this game, the player must tap two sensors repeatedly
* in order to run laps. One LED will light up per lap.
* When all laps are completed, LEDs will blink in victory.
*
* (c) 2013-2016 Arduino LLC.
*/

#include <EducationShield.h>

/*
  An array of pin numbers to which LEDs are attached
  the defaults are 2 to 6 but you can choose any of the digital pins
  just remember to leave digital pin 2,3 and 4 for the capacitive switches
*/
int ledPins[] = {8, 9, 10, 11, 13};
int pinCount = 5;
//This variable will let us keep track on which LED to turn on
int LED = 0;
VUMeter scoreBoard;

//Configure the capacitive sensors
int capacitiveSensorThreshold=200000;
CapacitiveSwitch leftFoot=CapacitiveSwitch(2,3);
CapacitiveSwitch rightFoot=CapacitiveSwitch(2,4);
CapacitiveSwitch me=CapacitiveSwitch(2,3);
int score;

void setup(){
  //initializing the game, set up all the components and variables
  score=0;
  Serial.begin(9600);
  //Connect scoreboard
  scoreBoard.config(pinCount,ledPins);
  scoreBoard.begin();

  //initialize left and right "foot"
  leftFoot.config(capacitiveSensorThreshold);
  rightFoot.config(capacitiveSensorThreshold);
}

void loop(){
  //Wait for the left foot to be pressed
   leftFoot.pressed();
   scoreBoard.on(LED);
  
  //Wait for the right foot to be pressed
  rightFoot.pressed();
  scoreBoard.off(LED);
  
  score=score+1; //After both feet are pressed, add one point
  
  //Every 20 points light up a led
  LED =score/20;
  scoreBoard.fill(LED);
  
 //When you get 100 points, you win
  if(score>100){
    //if you win, blink all leds for celebration
    //See vuMeter in refence list to make your own blink animation
    scoreBoard.blinkAll(50,5);
    //and reset the game
    score=0;
  leftFoot.test();
  delay(30);
  }
}


We are currently working on the racing project in block 2. We are VERY confident that all the wiring and other hardware stuff are done correctly (checked over 7 times with 3 different people). Moreover, we checked whether or not the capacitive switch recognizes human touch; which we found out that it does indeed recognize it (based on the capacitive switch test).
Therefore, we assumed that the problem was within the code. When we uploaded the code above, only the first two - red and yellow - LEDs were lit up and it didn't go any farther from there. No values showed up in the serial monitor when we uploaded the code above. Also, touching the aluminum foil seemed to do nothing, so we had to take the wire off the foil and touch the metal part of the wire ourselves.



Do any of you have a similar problem or have solutions for this? IT IS EXTREMELY URGENT! ANY HELP WILL BE GREATLY APPRECIATED! THE PROJECT IS DUE IN 11 HOURS!!!

Thank you in advance! :D

pert

Moreover, we checked whether or not the capacitive switch recognizes human touch; which we found out that it does indeed recognize it (based on the capacitive switch test).
Please explain exactly what you mean by "capacitive switch test".

No values showed up in the serial monitor when we uploaded the code above.
There's no prints to serial in your sketch. Maybe there are some in the libraries, I wouldn't know because you didn't provide any information about them. An extremely valuable technique for troubleshooting is to add debug Serial.println() statements throughout your sketch so that you can see what's actually happening. You can always remove or disable them later when things are working correctly.

mario-r

Hi Najeff2.

Can you please post your question in the CTC forum or send it to ctc.101@arduino.cc

Regards

Go Up