evantee
Published © GPL3+

1 segment display from joystick

This lets you control a one segment display with a joystick

IntermediateFull instructions provided1,214
1 segment display from joystick

Things used in this project

Hardware components

Analog joystick (Generic)
×1
7 Segment LED Display, InfoVue
7 Segment LED Display, InfoVue
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

sketch

Code

sketch

Arduino
#define joyX A0
#define joyY A1
int  xValue, yValue;
int mid = 3, topl=4,topm=5,topr=6, botl=8,botm=9,botr=10, but=11,butt=2;
int buttonState = 0;
void setup() {
  pinMode(butt,INPUT);
  pinMode(mid,OUTPUT);
  pinMode(topl,OUTPUT);
  pinMode(topm,OUTPUT);
  pinMode(topr,OUTPUT);
  pinMode(botl,OUTPUT);
  pinMode(botm,OUTPUT);
  pinMode(botr,OUTPUT);
  pinMode(but,OUTPUT);
  Serial.begin(9600);
}
 
void loop() {
  // put your main code here, to run repeatedly:
  xValue = analogRead(joyX);
  yValue = analogRead(joyY);
  buttonState = digitalRead(butt);
 if(xValue==509&& yValue==520)
 {
  digitalWrite(mid,HIGH);
 }
 else
 {
  digitalWrite(mid,LOW);
 }
  if(xValue==0&& yValue==1023)
 {
  digitalWrite(topl,HIGH);
 }
 else
 {
  digitalWrite(topl,LOW);
 }
  if(xValue==0&& yValue==520)
 {
  digitalWrite(topm,HIGH);
 }
 else
 {
  digitalWrite(topm,LOW);
 }
  if(xValue==0&& yValue==0)
 {
  digitalWrite(topr,HIGH);
 }
 else
 {
  digitalWrite(topr,LOW);
 }
   if(xValue==509&& yValue==0)
 {
  digitalWrite(topr,HIGH);
  digitalWrite(botr,HIGH);
 }
 else
 {
  digitalWrite(topr,LOW);
   digitalWrite(botr,LOW);
 }
    if(xValue==510&& yValue==1023)
 {
  digitalWrite(topl,HIGH);
  digitalWrite(botl,HIGH);
 }
 else
 {
  digitalWrite(topl,LOW);
   digitalWrite(botl,LOW);
 }
  if(xValue==1023&& yValue==520)
 {
  digitalWrite(botm,HIGH);
 }
 else
 {
  digitalWrite(botm,LOW);
 }
   if(xValue==1023&& yValue==1023)
 {
  digitalWrite(botl,HIGH);
 }
 else
 {
  digitalWrite(botl,LOW);
 }
    if(xValue==1023&& yValue==0)
 {
  digitalWrite(botr,HIGH);
 }
 else
 {
  digitalWrite(botr,LOW);
 }
if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(but, HIGH);
  } else {
    // turn LED off:
    digitalWrite(but ,LOW);
  }


  
  //print the values with to plot or view
  Serial.print(xValue);
  Serial.print("\t");
  Serial.println(yValue);
}

Credits

evantee

evantee

3 projects • 1 follower

Comments