Hello.. new to all of this and at 50 I wonder why Ive started... easy.. SIM Racing
I have an F1 wheel for my rig.. I have added 3 buttons and 1 rotary encoder.. despite several attempts... I cant get it to work.
Rotary is a Left and Right 360 with a much button centre.
I have 3 momentary buttons. 2 sharing ground and then each with own +
a third is to select Neutral
but for the life of me I just cant get anything to work.
The next step is to post a circuit diagram and a full listing of your code. In the Arduino IDE, select all your code, then click the menu Edit | Copy for Forum. Paste that into your message.
#include <Keyboard.h>
int A; //A variable
int B; //B variable
int r = 0; //r variable
void setup() //Initial function. Performed once at the beginning
{
attachInterrupt(0, STEP, CHANGE); //Contact 2-nd(interrupt0) as an interrupt Pin
attachInterrupt(1, BUTTON, CHANGE); //Contact 3-rd(int1) as an interrupt Pin
pinMode(4, INPUT); //Contact 4-th as input
Serial.begin(9600); //Serial port initialization. Speed 9600
}
void loop() //Main function
{
}
void STEP() //Step function
{
A = digitalRead(2); //Read value from 2-nd(interrupt0) Pin
B = digitalRead(4); //Read value from 4-th Pin
if (A != B) //Compare values
{
r++; //Add 1 to the value of the variable 'r'
} else
{
r--; //Subtract 1 from the value of the variable 'r'
}
Serial.println(r); //Print 'r' value
}
void BUTTON() //Button function
{
if (digitalRead(3) == HIGH) //If signal from 3-rd Pin is HIGH
{
Serial.println("Button ON"); //Print "Button ON"
} else if (digitalRead(3) == LOW) //Else if signal from 3-rd Pin is LOW
{
Serial.println("Button OFF"); //Print "Button OFF"
}
}
I was trying to check if my BMP280 sensor worked by doing the I2C scanner test which worked and the BMP280 test which did not work. I know my wiring is correct which leads me to believe that the code might be incorrect. However, l got the code from a certain website so l am not 100% sure. If someone could give me code that works or sees what's wrong with the code that would be great. Thanks.
//if (!bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID)) {
if (!bmp.begin()) {
Serial.println(F("Could not find a valid BMP280 sensor, check wiring or try a different address!"));
while (1) delay(10);
}