Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Nivedh
Published

Jump counter device using Arduino -Jumping game

Using Atmega328p to create a jump counter device with timer. Suitable for fun filled fitness activity that lets you do jumping exercise.

BeginnerFull instructions provided506
Jump counter device using Arduino -Jumping game

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
tm1637 7 segment display module
×1
Custom PCB
Custom PCB
×1
Through Hole Resistor, 330 ohm
Through Hole Resistor, 330 ohm
×8
Resistor 10k ohm
Resistor 10k ohm
×1
Through Hole Resistor, 1 Mohm
Through Hole Resistor, 1 Mohm
×1
Gravity:Digital Push Button (Yellow)
DFRobot Gravity:Digital Push Button (Yellow)
×1
5 mm LED: Red
5 mm LED: Red
×1
Ceramic Disc Capacitor, 22 pF
Ceramic Disc Capacitor, 22 pF
×2
Capacitor 10 µF
Capacitor 10 µF
×1
16mhz clock crystal
×1
aluminium foil
×1
7 Segment LED Display, InfoVue
7 Segment LED Display, InfoVue
×1
atmega328p dip
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

program code

Arduino
#include <TM1637.h>
#include <CapacitiveSensor.h>

CapacitiveSensor sensor1 = CapacitiveSensor (9,10);                                                   

int CLK = 12;
int DIO = 13;
int i;
TM1637 tm(CLK,DIO);
int y=0;
long mytime = 0;
long mytme2 = 0;
int al2=0;
long total1=0;
long total3;
int ar[10];
int x;
int z=0;
int counter=1; 

void setup() {
  
  pinMode (2,OUTPUT);
  pinMode (3,OUTPUT);
  pinMode (4,OUTPUT);
  pinMode (5,OUTPUT);
  pinMode (6,OUTPUT);
  pinMode (7,OUTPUT);
  pinMode (8,OUTPUT);
  tm.init();
  tm.set(4);
  randomSeed (analogRead(0));// put your setup code here, to run once:
  pinMode (11,OUTPUT);

  Serial.begin(9600);
  // put your setup code here, to run once:
}

void loop() {
  digitalWrite (11,HIGH);
  do{
  total1=0;
  total1 = sensor1.capacitiveSensor(30);
  Serial.print(total1);
  Serial.print('\n');
  }
 while(total1<130);

while(al2==0){
 mytime=random (5000,10000);
 Serial.println("ello");
 digitalWrite(11,LOW);
 delay(mytime);
 digitalWrite(11,HIGH);
 total3=0;
 total3=sensor1.capacitiveSensor(30);
    for(y=0;total3<120;y++){
           total3=sensor1.capacitiveSensor(30);
           ar[y]=1;
           x=x+ar[y];
          if(x>900){
           light7(9);
           z=5;
          }
           else if(x>800){
           light7(8);
           z=5;
           }
           else if(x>700)
           {
           light7(7);
           z=4;}
           else if(x>600){
           light7(6);
           z=4;}
           else if(x>500){
           light7(5);
           z=3;}
           else if(x>400){
           light7(4);
           z=2;}
           else if(x>300){
           light7(3);
           z=1;}
           else if(x>200){
           light7(2);
           z=1;
           }
           else if(x>100){
           light7(1);
           z=1;}
          Serial.print(x);
      Serial.print("ngha");
      Serial.print('\n');
    }
    counter=counter+3;
    counter=counter-z;
    displayNumber(counter);
    Serial.print(counter);
    x=0;
    }
 
}
void displayNumber(int num){   
    tm.display(3, num % 10);   
    tm.display(2,num / 10 % 10);   
    tm.display(1, num / 100 % 10);   
    tm.display(0,num/ 1000 % 10);
}
void light7(int num){
  switch (num)
  {
 case 0 : digitalWrite (2,HIGH);
           digitalWrite (3,HIGH);
           digitalWrite (4,HIGH);
           digitalWrite (5,LOW);
           digitalWrite (6,HIGH);
           digitalWrite (7,HIGH);
           digitalWrite (8,HIGH);
 break;
       

case 1 : digitalWrite (2, HIGH);
         digitalWrite (3, LOW);
         digitalWrite (4,LOW);
         digitalWrite (5,LOW);
         digitalWrite (6,LOW);
         digitalWrite (7,HIGH);
         digitalWrite (8,LOW);
 break;      

 case 2 : digitalWrite (2, HIGH);
         digitalWrite (3, HIGH);
         digitalWrite (4,LOW);
         digitalWrite (5,HIGH);
         digitalWrite (6,HIGH);
         digitalWrite (7,LOW);
         digitalWrite (8,HIGH);
 break;      

 case 3 : digitalWrite (2, HIGH);
         digitalWrite (3, HIGH);
         digitalWrite (4,LOW);
         digitalWrite (5,HIGH);
         digitalWrite (6,LOW);
         digitalWrite (7,HIGH);
         digitalWrite (8,HIGH);
 break;      

case 4 : digitalWrite (2, HIGH);
         digitalWrite (3, LOW);
         digitalWrite (4,HIGH);
         digitalWrite (5,HIGH);
         digitalWrite (6,LOW);
         digitalWrite (7,HIGH);
         digitalWrite (8,LOW);
 break;      

 case 5 : digitalWrite (2, LOW);
         digitalWrite (3, HIGH);
         digitalWrite (4,HIGH);
         digitalWrite (5,HIGH);
         digitalWrite (6,LOW);
         digitalWrite (7,HIGH);
         digitalWrite (8,HIGH);
 break;      

 case 6 : digitalWrite (2, LOW);
         digitalWrite (3, HIGH);
         digitalWrite (4,HIGH);
         digitalWrite (5,HIGH);
         digitalWrite (6,HIGH);
         digitalWrite (7,HIGH);
         digitalWrite (8,HIGH);
 break;      

case 7 : digitalWrite (2,HIGH);
           digitalWrite (3,HIGH);
           digitalWrite (4,LOW);
           digitalWrite (5,LOW);
           digitalWrite (6,LOW);
           digitalWrite (7,HIGH);
           digitalWrite (8,LOW);
 break;

 case 8 : digitalWrite (2,HIGH);
           digitalWrite (3,HIGH);
           digitalWrite (4,HIGH);
           digitalWrite (5,HIGH);
           digitalWrite (6,HIGH);
           digitalWrite (7,HIGH);
           digitalWrite (8,HIGH);
 break;

 case 9 : digitalWrite (2, HIGH);
         digitalWrite (3, HIGH);
         digitalWrite (4,HIGH);
         digitalWrite (5,HIGH);
         digitalWrite (6,LOW);
         digitalWrite (7,HIGH);
         digitalWrite (8,HIGH);
 break;     

 default : digitalWrite (2,HIGH);
           digitalWrite (3,HIGH);
           digitalWrite (4,HIGH);
           digitalWrite (5,LOW);
           digitalWrite (6,HIGH);
           digitalWrite (7,HIGH);
           digitalWrite (8,HIGH);
 break;
       
  }

}

Credits

Nivedh

Nivedh

3 projects • 32 followers
A passionate Electronics and communication engineering student who loves to make & invent new stuffs. Good at programing & hardware field.

Comments