I have a problem with uploading the code to my arduino nano - arduino

I am trying to upload this code:
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
To my arduino nano, and I get this message:
Arduino: 1.8.13 (Mac OS X), Board: "Arduino Nano, ATmega328P (Old Bootloader)"
fork/exec /Users/vladimir/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++: no such file or directory
Error compiling for board Arduino Nano.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Could someone help me with this?

this error usually occurs if you have a old Arduino Nano board.
Try changing the processor in the Arduino IDE
Tools--> Processor --> ATmega328p (Old Bootloader)
If the error persists still, try choosing the other processors in the list and upload the code.
If the code does not upload even after changing the processors in the IDE, there is a chance for your Arduino Nano board to be damaged.

This error is not caused by #includes. This is caused by a glitch in the Arduino IDE or the Arduino AVR Boards installation. Maybe try reinstalling Arduino IDE

Related

Arduino and Processing - RX is blinking on board, but LED is not lighting up

I am trying to run a Processing sketch with my Arduino. I got it a few days ago, so I'm pretty much a noob. I made two similar sketches - one in Arduino and one in Processing. The Arduino one does work, while the Processing sketch doesn't, even though when running the Processing one, the RX lights up on the board.
I have connected an LED into the D9 on the board, with a 220 ohm resistor, and plugged the other leg into the GND. I then proceeded to run the Arduino sketch, which is a simple one, it lights up and down the LED for a second. This one worked.
I then tried running the Processing sketch, exact same code ( adapted for Processing ) using the library for Arduino, and the board seems to communicate with my sketch, as the RX is blinking each second on the board ( I tried different intervals of time and they match with the intervals at which the RX blinks ), but the LED does not turn on and off, like it did with the Arduino sketch.
I tried getting only a serial connection between the Arduino, and it worked - I connected a joystick module to the Arduino and sent the X and Y through the serial port, and the Processing sketch received the information through the serial port, so they are, indeed, communicating.
The port used is COM3 and is running at 9600 baud.
This is the Arduino sketch :
void setup() {
pinMode(9, OUTPUT);
}
void loop() {
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
}
and this is the Processing ( version 3.4 ) sketch :
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup() {
arduino = new Arduino(this, Arduino.list()[0], 9600);
arduino.pinMode(9, Arduino.OUTPUT);
}
void draw() {
arduino.digitalWrite(9, Arduino.HIGH);
delay(1000);
arduino.digitalWrite(9, Arduino.LOW);
delay(1000);
}
Well done on step by step debugging such as double checking the wiring on the electronics side and testing the blink code with the Arduino alone to isolate the issue.
If the Blink sketch is the only Arduino code you have uploaded to your board that won't suffice. Processing does send messages to Arduino (which is why you see the RX LED turn on), but there's nothing in the Arduino code that initialises Serial communication
As you can see in that example, in setup() Serial communication is initialised with 9600 baud rate (communication speed, 9600 bytes/chars per second):
Serial.begin(9600);
Then in draw() if there is data available, each character is read, then printed one at a time with a prefixed message:
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
If you upload the example linked, if you've got a single Serial port, you should see both the RX then ever so slightly after the TX LED blinking when you run your Processing sketch. If you close that sketch, open Serial Monitor in Arduino and type something then press enter you'll see the debugging message read back from Arduino.
Using these notions you could write a basic sketch like so:
int incomingByte = 0; // for incoming serial data
void setup() {
pinMode(9, OUTPUT);
Serial.begin(9600);
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
// if we received ASCII character '1', turn LED on
if(incomingByte == '1'){
digitalWrite(9,HIGH);
}
// if we received ASCII character '0', turn LED off
if(incomingByte == '0'){
digitalWrite(9,LOW);
}
}
}
Uploading this sketch to your Arduino should allow you to type 1 into Serial Monitor and press Enter to turn the LED on or 0 to turn it off.
The only thing left is to send the same data from Processing:
import processing.serial.*;
Serial arduino;
void setup(){
try{
arduino = new Serial(this, Serial.list()[0], 9600);
}catch(Exception e){
println("error connecting to serial port, double chek USB connection, serial port and close other programs using Serial");
e.printStackTrace();
}
}
void draw(){
}
void keyPressed(){
if(key == '1'){
if(arduino != null){
arduino.write('1');
}else{
println("arduino serial connection wasn't initialised");
}
background(255);
}
if(key == '0'){
if(arduino != null){
arduino.write('0');
}else{
println("arduino serial connection wasn't initialised");
}
background(0);
}
}
Minor side note: notice I'm not using delay() in Processing, I recommend using millis() instead as it doesn't block the execution of code like delay() does.
So the above looks like quite a bit of code just to blink an LED but the point is to understand the basics of Serial communication which will be useful on the long run:
initialising serial communication with Arduino (understand baud rate)
basic reading/writing of bytes over Serial
initialising serial communication from Processing and sending data
Back to your original question, you've missed an important detail regarding the Arduino library you're using in Processing: it's relying on a special Arduino sketch (firmware) called Firmata. You will be able to read more on that and how to use the library in this Arduino and Processing tutorial.
As the tutorial mentions you need to first upload this sketch from Arduino > Examples > Firmata > StandardFirmata. Also bare in mind baud rate is set to 57600, not 9600 so you need to update your code like so:
arduino = new Arduino(this, Arduino.list()[0], 57600);
To use: are you sure to put the standardfirmata
Using the Arduino software, upload the StandardFirmata example (located
in Examples > Firmata > StandardFirmata) to your Arduino board.
change the line
arduino = new Arduino(this, Arduino.list()[0], 9600);
to:
arduino = new Arduino(this, "COM3", 57600); // in Firmata -> Firmata.begin(57600);
you could add this line to look after your serial port:
println(Arduino.list());
Modify the "arduino = new Arduino(...)" line below, changing the number in Arduino.list()[0] to the number corresponding to the serial port of your Arduino board. Alternatively, you can replace Arduino.list()[0] with the name of the serial port, in double quotes, e.g. "COM3" on Windows or "/dev/tty.usbmodem621" on Mac.
I got it working with Arduino but I had to change some details. My port was "COM3" or Arduino.list()[1] (the 2nd port on the list) which you can check in Windows device manager (Ports COM & LPT: USB-SERIAL) after installing the latest drivers (maybe on the usb port that appears when you connect your Arduino under other devices) using the system update and restarting, then you may need to repeat the system update and restart 2 or 3 times. Or on Linux, you can find which port it's on with:
ls /dev/ttyUSB*
Then unplug it and check it again.
First I had to upload the Arduino IDE program (running it with the serial monitor window from the tools menu ctrl-shft-m after having the same exact baud rate on the lower right menu option as in the program). Then I could close it and compile the processing one as long as I had input that very same baud rate into the Processing program too. All 3 different bauds that I tried, 9600, 57600, 115200, worked requiring their equality between Arduino IDE, Arduino IDE Serial Monitor and Processing. If I uploaded a different project in IDE, then Processing did not even connect to the Arduino, so it had to be that same project running on it for Processing to communicate with Arduino Uno properly. Processing is basicly USING Arduino IDE by sending or receiving messages already programmed for it to do, it doesn't program the Arduino in this case. I have even gone through a big mess, trying to get Visual Micro to work (Arduino on Visual Studio) cross-platform but it still would not allow me to link other libraries and headers because of how picky Arduino's programming is! One of the best ways to learn is to check the actual arduino.cc or Processing manual command parameters after finding out where your problem is.

Wemos D1 not able to run code

I bought this board
As far as I can tell I installed the drivers and libraries properly(I can see the board in the usb devices and upload the code), but every time I try to run a program, I get this result in the serial monitor and the board doesnt light up any led. I also tried to just print an hello world, but i get the same result.
My configs are :
And a example is:
I hope you can help me out, thank you!
I think the issue with the LED not blinking is because many of the ESP12 boards use GPIO 2 rather than GPIO 1 for the built in LED.
See this issue for more details.
Try adding this to the beginning of the sketch:
#define LED_BUILTIN 2
or just use 2 in place of LED_BUILTIN
which will re-define LED_BUILTIN to use gpio 2 rather than gpio 1
As for the serial monitor, I have not directly used the Arduino IDE in a while, but you are not printing anything to the serial port anyway.
Here is an updated version of the sketch that should blink the led and print some messages to the monitor. (set the baud rate of the serial port to 115200 in the IDE)
#define LED_BUILTIN 2
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
Serial.println("turning ON LED");
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is acive low on the ESP-01)
delay(1000); // Wait for a second
Serial.println("turning OFF LED");
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000); // Wait for two seconds (to demonstrate the active low LED)
}
The problem in my case was a faulty board. I requested a new one from the seller, and the one worked just fine with the code that I provided in the question.

LED of pin 13 in Arduino Uno always on even if there is no program uploaded to it

I have purchased a brand new Arduino Uno today. While it was connected to the PC, the LED (pin 13) was always remaining on. I have uploaded a blank program, but the LED doesn't go off.
Help me with this issue, please. I am in a fix about it.
The Arduino does not remember any states which have been set before a new program start. Without setting the digital port 13 the LED is turned on. You can set the port 13 by program (using it as output port) or you pull down the port by connecting it to ground (using it as input port).
Also see tutorial about digital pins on the Arduino website.
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, LOW);
}

Connect Arduino to Blynk with ESP8266

so I got my Arduino Uno today. For a porject I want to be able to control some relays on my Arduino via Wifi (via Blynk app). For this I want to use the ESP8266-01 as a Wifi shield.
I used this tutorial: https://create.arduino.cc/projecthub/nolan-mathews/connect-to-blynk-using-esp8266-as-arduino-uno-wifi-shield-m1-46a453
Only difference is I'm using Win10. Here is what I got:
Arduino Uno R3
Arduino IDE 1.8.1
included all Blynk/ESP libraries and installed ESP8266 as board (generic)
uploaded empty sketch to the Arduino
Connections to Between Arduino/ESP as follows . http://www.teomaragakis.com/hardware/electronics/how-to-connect-an-esp8266-to-an-arduino-uno/ (I know about to 3.3V to 5V issue but seems to work so far)
Okay, first problem is that I couldnt flash the Firmware of the ESP (got it from Sunfounder) as said in the Tutorial. Downloaded the latest firmware and flashed it with ESP8266Flasher.
Other Problem that is when I try to compile the code from the first tutorial, I always get error :
C:\Users\Chris\Documents\Arduino\libraries\Blynk\examples\Boards_WiFi\ESP8266_Shield\ESP8266_Shield.ino:5:21: fatal error: ESP8266.h: No such file or directory
As said I have installed all libraries. Cant really think of things to do anymore. Any help would be much appreciated. Best regards from Berlin, Chris.
To close the code I try to upload to the board (both Arduino Board or generic ESP8266 does not work)
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266.h>
#include <BlynkSimpleShieldEsp8266.h>
// Set ESP8266 Serial object
#define EspSerial Serial
ESP8266 wifi(EspSerial);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "???";
void setup()
{
Serial.begin(115200); // Set console baud rate
delay(10);
EspSerial.begin(115200); // Set ESP8266 baud rate
delay(10);
Blynk.begin(auth, wifi, "???",
"???");
}
void loop()
{
Blynk.run();
}
The ??? I switched for my token and data ofc.
Try changing this
#include <ESP8266.h>
to this
#include <ESP8266_Lib.h>
The file was renamed in this commit.

Arduino YUN: Serial Communication not working

I have been unable to use the serial monitor with the Arduino YUN, I can download the compiled sketch with IDE 1.5.5 (on Windows XP via the USB connector that appears as COM6), the serial monitor opens but displays nothing. In order to investigate I modified the Blink example sketch as follows:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
Serial.begin(9600);
while (!Serial) {;}
Serial.println("Blink Program");
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.println("Blink Program -H");
delay(5000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
Serial.println("Blink Program -L");
delay(5000); // wait for a second
}
The sketch upoloads and runs, I see the LED blinking, it does not wait for SerialMonitor to open. The SerialMonitor displays nothing. I have noticed that during the upload COM6 disappers from the Windows device manager, a new port COM7 appears, the upload completes successfully, COM7 disappears and COM6 reappears.
I have also found that the YunSerialTerminal example is not working.
Do other people have successfully used the IDE 1.5.5 SerialMonitor on Windows XP?
Should I conclude that my Arduino Yun board is malfunctioning?
Any help would be greatly appreciated.
I had the same problem. A reset on 32U4 solved the problem (the button on the left top corner, next to the Ethernet connector). The serial port appeared on the arduino 1.5.x IDE and the connection was established and the data received.
Bridge and Console should be used when the selected port is the wifi one, not the real serial port.
I hope that helps.
Best,
I am running 1.5.5 and had a similar problem. Console.begin() and Bridge.begin() work just fine. Serial gives me nothing. I started with the following.
void setup() {
// for debugging, wait until a serial console is connected
Serial.begin(9600);
delay(4000);
while(!Serial);
Serial.print("Initializing the bridge...");
Bridge.begin();
Serial.println("Done");
}
void loop()
{
Serial.println("running...");
}
Try to change your USB cable(needs to be USB data cable) and Port settings in Arduino IDE. Tools-->Port-->COM6(Arduino Yun).
This solved my problem in Windows.

Resources