Passion Project Check In-24/5

#include
#define VRX_PIN  A0 // Arduino pin connected to VRX pin
#define VRY_PIN  A1 // Arduino pin connected to VRY pin
#define SW_PIN   2  // Arduino pin connected to SW  pin
ezButton button(SW_PIN);
int xValue = 0; // To store value of the X axis
int yValue = 0; // To store value of the Y axis
int bValue = 0; // To store value of the button
int pin12 = 12;
int pin13 = 13;
int pin11 = 11;
int pin10 = 10;
int pin9 = 9;
int pin6 = 6;
void setup() {
  Serial.begin(9600) ;
  button.setDebounceTime(50); // set debounce time to 50 milliseconds
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(11, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
}
void loop() {
  button.loop(); // MUST call the loop() function first
  // read analog X and Y analog values
  xValue = analogRead(VRX_PIN);
  yValue = analogRead(VRY_PIN);
  // Read the button value
  bValue = button.getState();
  if (button.isPressed()) {
    Serial.println(“The button is pressed”);
    digitalWrite(10, LOW);
  digitalWrite(9, LOW);
  }
  if (button.isReleased()) {
    Serial.println(“The button is released”);
    // TODO do something here
  }
  // print data to Serial Monitor on Arduino IDE
  Serial.print(“x = “);
  Serial.print(xValue);
  Serial.print(“, y = “);
  Serial.print(yValue);
  Serial.print(” : button = “);
  Serial.println(bValue);
  //joystick code
 if (yValue > 492) {
  digitalWrite(10, HIGH);
 digitalWrite(9, LOW);
 digitalWrite(11, LOW);
 }
if (yValue < 491){
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
//if (yValue = 491){
//digitalWrite(11, HIGH);
//digitalWrite(10, LOW);
//digitalWrite(9, LOW);
//}
}

What you see is my code. I have looked over my goal list and made the executive decision to
start using a joystick. Currently, with it, I can spin my motor forward and brake, and kind of backwards.

Then, when this is fixed, hopefully by next class, I will begin assembling the body.
Skip to toolbar