How to address arduino mega multiple serial (Rx/Tx) pin?
Simply call it by the number e.g:
Serial1.begin(9600), Serial2.begin(9600), Serial3.begin(9600)
Coin Hopper Relay Interrupt Issue
I had a coin hopper that is use to give change on a vendo machine project. Coin hopper will turn on after relay triggers thats is controlled by Arduino. When a coin is release, it then give signal to the arduino on an interrupt pin. The scenario is that when the interrupt is trigger it will decrement the amount of change given and the problem is that it will instantly update to zero right after the coin hopper is turn on. The reason being is that the interrupt was trigger even there was no coin release. My solution to the problem is instead of using interrupt, I do….while loop in and logic is turn on the coin hopper in do statement and check the amount of change give in while e.g. while the change amount is not zero. Make sure you add a delay of 100ms.
Sample code:
do {
digitalWrite(relayPin, LOW) //this how you turn the relay module
if(digitalRead(hopperInput) == HIGH){
changeAmount--;
delay(100);
}
} while (changeAmount != 0)
Leave a Reply