Hello! I just started learning about Arduino and I can't figure out what is wrong or how to modify my code. I have a code (just got this from the internet) for a QR code scanner, just a simple code to display the data from the QR code. At first, I tried it in Arduino Uno and it worked just fine but when I tried it in Arduino Mega it does not work and I am not sure why. This is the code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // TX, RX
void setup()
{
Serial.begin(9600);
mySerial.begin(9600); // set the data rate for the SoftwareSerial port
Serial.println("Barcode scanner Arduino");
}
void loop()
{
if (mySerial.available()) // Check if there is Incoming Data in the Serial Buffer.
{
scanQRCode();
}
}
void scanQRCode()
{
while (mySerial.available()) // Keep reading Byte by Byte from the Buffer till the Buffer is empty
{
char input = mySerial.read(); // Read 1 Byte of data and store it in a character variable
Serial.print(input); // Print the Byte
delay(5); // A small delay
}
Serial.println();
}
What should I do to make it work? I need this to work on Arduino Mega because I will use this together with other components such as GSM module, temperature sensor, LCD, etc. and Uno might not be enough for the whole project. Thank you very much in advance and Happy New Year! (Sorry I'm not sure about the category of this post I just selected something I though it would be)
But let me guess for this round... When you changed Arduinos (assuming you did not change computer, which will require you to install the tiny88 drivers on the new computer), you will need to change the IDE "tools >> board >> avr..." board type. Next, you will need to select the programmer "tools >> programmer >> micronucleous"... then here is the tricky part: you need to "compile/upload" BEFORE inserting the USB/tiny88... wait for "Plug in device now... (will timeout in 60 seconds)" then insert your USB/tiny88.
Hello, sorry I'm still not familiar of the terms that you named. I just selected the board with their COM ports on the combo box near the verify and upload buttons. On how it does not work, when I use Arduino Uno, and everytime I scan a QR code, it will display the data scanned on the Serial monitor but when I use Mega, it will not display the data no matter how much I scan.
Hello, when I moved the wires I just matched what pins I put the wires in Uno and in Mega. In this case the pins 2 and 3. Are they different between the boards? I just started learning so I am not sure if there are specific pins I should use in mega for this to work.
Before trying to discover why no data appears in the Serial Monitor, discover if the MH-ET-Live-ATtiny88 and the MEGA work together. Start a new sketch (File >> Examples >> Basic >> Blink). Edit the LED_BUILTIN to 0 (zero for the tiny88). Does this upload? (The Blink example blinks the LED at 1Hz, but the installed tiny88 "blink" sketch makes the LED flicker for half a second, and is off for half a second)