Arduino Micro Slider

Hello!

I’m new to coding and have been modifying old/broken guitar hero guitars. I wrote some simple code for the arduino micro to just activate buttons to keyboard keys here

#include "Keyboard.h"
 
void setup() {
 
Keyboard.begin();
 
//Joystick and button connections
pinMode(2, INPUT_PULLUP); //Green Button
pinMode(3, INPUT_PULLUP); //Red Button
pinMode(4, INPUT_PULLUP); //Yellow Button
pinMode(5, INPUT_PULLUP); //Blue Button
pinMode(6, INPUT_PULLUP); //Orange Button
pinMode(7, INPUT_PULLUP); //Strum up
pinMode(8, INPUT_PULLUP); //Strum Down
pinMode(9, INPUT_PULLUP); //Start
pinMode(10, INPUT_PULLUP); //Select
}
 
void loop() {
 
// Check the switches:
int buttonState2 = digitalRead(2);
int buttonState3 = digitalRead(3);
int buttonState4 = digitalRead(4);
int buttonState5 = digitalRead(5);
int buttonState6 = digitalRead(6);
int buttonState7 = digitalRead(7);
int buttonState8 = digitalRead(8);
int buttonState9 = digitalRead(9);
int buttonState10 = digitalRead(10);
 
// Green Button
if (buttonState2 == LOW) {
Keyboard.press(194);
}
else {
Keyboard.release(194);
}
 
// Red Button
if (buttonState3 == LOW) {
Keyboard.press(195);
}
else{
Keyboard.release(195);
}
 
// Yellow Button
if(buttonState4 == LOW) {
Keyboard.press(196);
}
else{
Keyboard.release(196);
}
 
// Blue Button
if (buttonState5 == LOW) {
Keyboard.press(197);
}
else{
Keyboard.release(197);
}
 
// Orange Button
if (buttonState6 == LOW) {
Keyboard.press(198);
}
else{
Keyboard.release(198);
}
 
// Strum Up
if (buttonState7 == LOW) {
Keyboard.press(133);
}
else{
Keyboard.release(133);
}
 
// Strum Down
if (buttonState8 == LOW) {
Keyboard.press(176);
}
else{
Keyboard.release(176);
}
 
// Start
if (buttonState9 == LOW) {
Keyboard.press(129);
}
else{
Keyboard.release(129);
}
 
// Select
if (buttonState10 == LOW) {
Keyboard.press(128);
}
else{
Keyboard.release(128);
}
}

I wanted to try and get the whammy bar working but i’m not sure how to go about getting this working. The whammy bar is attached to a spring and when pushed it turns a single turn encoder (not sure the exact name it turns around 85% or 90% and stop) so the game reads it as 30% back and forth movement as a slider of sorts.

if anyone can help me me with this section or if it’s even possible with a micro that would be great!

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks… Tom… :slight_smile:

Sorry about that! I updated the main post with the code. As for the circuit, i’ve never made one before but I threw this together for what I have with it now. I’ve attached that.

Also to clarify a little bit, by slider I mean like the X axis/Z axis sliders in the game controller settings on windows, Attached a screenshot of what I mean

Another thing, I meant to put Arduino Micro not the nano.

2Q7aJ.png