#include <LiquidCrystal.h>
#include <SPI.h>
#include <Wire.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
String importent_message = "spaghetti";
int Switch = 0;
byte volume = 0x27;
const int sckpin = 13;
const int dinpin = 11;
const int cspin = 10;
const int joystickXPin = A0;
const int joystickYPin = A1;
int joystickXValue = 0;
int joystickYValue = 0;
const int joystickThreshold = 5;
double fmfake = 88.0;
void setup() {
pinMode(49, INPUT);
pinMode(sckpin, OUTPUT);
pinMode(dinpin, OUTPUT);
pinMode(cspin, OUTPUT);
pinMode(SS, OUTPUT);
SPI.begin();
lcd.begin(16, 2);
digitalWrite(cspin, LOW);
Serial.begin(9600);
pinMode(joystickXPin, INPUT);
lcd.setCursor(1, 0);
lcd.print("fakefm");
pinMode(joystickYPin, INPUT);
lcd.setCursor(8, 0);
lcd.print(fmfake);
lcd.setCursor(1, 1);
lcd.print(volume);
Wire.begin();
lcd.setCursor(1, 6);
lcd.print("volume");
}
void loop() {
joystickXValue = analogRead(joystickXPin);
joystickYValue = analogRead(joystickYPin);
if (Switch == 0) {
if (joystickXValue < 512 - joystickThreshold) {
fmfake += 0.1;
lcd.setCursor(8, 0);
lcd.print(fmfake);
Serial.println("Joystick moved left");
} else if (joystickXValue > 512 + joystickThreshold) {
fmfake -= 0.1;
lcd.setCursor(8, 0);
lcd.print(fmfake);
Serial.println("Joystick moved right");
}
if (joystickYValue < 512 - joystickThreshold) {
Serial.println("Joystick moved down");
Switch += 1;
} else if (joystickYValue > 512 + joystickThreshold) {
Serial.println("Joystick moved up");
Switch -= 1;
}
} else {
if (joystickXValue < 512 - joystickThreshold) {
Serial.println("Joystick moved left");
volume += 1;
} else if (joystickXValue > 512 + joystickThreshold) {
volume -= 1;
Serial.println("Joystick moved right");
}
lcd.setCursor(1, 1);
lcd.print(volume);
if (joystickYValue < 512 - joystickThreshold) {
Serial.println("Joystick moved down");
Switch += 1;
} else if (joystickYValue > 512 + joystickThreshold) {
Serial.println("Joystick moved up");
Switch -= 1;
}
}
if (Switch < 0) {
Switch = 0;
} else if (Switch == 2) {
Switch = 1;
}
if (Switch == 1) {
lcd.setCursor(0, 1);
lcd.print(">");
lcd.setCursor(0, 0);
lcd.print(" ");
} else if (Switch == 0) {
lcd.setCursor(0, 0);
lcd.print(">");
lcd.setCursor(0, 1);
lcd.print(" ");
}
Serial.print(Switch);
delay(75);
}