I am reading pulses off of a 12v coin mechanism. I updated my code and I am now getting loads of false positives on the digital pin. I am wondering if I have shorted something on my board which is causing this. What do you guys think. Any questions please ask. I also tried my origional code and got the same issue. Below is my code
const int coinInt = 2;
//Attach coinInt to Interrupt Pin 0 (Digital Pin 2). Pin 3 = Interrpt Pin 1.
volatile float coinsValue = 0.00;
//Set the coinsValue to a Volatile float
//Volatile as this variable changes any time the Interrupt is triggered
volatile int coinsChange = 0;
//A Coin has been inserted flag
void setup()
{
// Serial.begin(9600);
//Start Serial Communication
attachInterrupt(coinInt, coinInserted, RISING);
//If coinInt goes HIGH (a Pulse), call the coinInserted function
//An attachInterrupt will always trigger, even if your using delays
}
void coinInserted()
//The function that is called every time it recieves a pulse
{
coinsValue = coinsValue + 0.05;
//As we set the Pulse to represent 5p or 5c we add this to the coinsValue
coinsChange = 1;
//Flag that there has been a coin inserted
}
void loop()
{
if(coinsChange == 1)
//Check if a coin has been Inserted
{
coinsChange = 0;
//unflag that a coin has been inserted
// Serial.print("Credit: £");
// Serial.println(coinsValue);
Keyboard.press('#');
delay(100);
Keyboard.releaseAll();
delay(300);
Keyboard.press('+');
delay(100);
Keyboard.releaseAll();
//Print the Value of coins inserted
}
}