Saturday, March 11, 2017

Ardiuno - Ubuntu - Setting up IDE to work with Ardiuno Uno R3 and run Blink Program

Step 1. Download Arduino IDE: https://downloads.arduino.cc/arduino-1.8.1-linux64.tar.xz


Step 2. Extract the package to: /home/sashank/Documents/Arduino_Projects/Tweak/arduino-1.8.1

Step 3. Run the install.sh:

 ~/Documents/Arduino_Projects/Tweak/arduino-1.8.1 $ ./install.sh
Adding desktop shortcut, menu item and file associations for Arduino IDE...touch: cannot touch '/home/sashank/.local/share/applications/mimeapps.list': Permission denied
mv: try to overwrite '/home/sashank/.local/share/applications/mimeapps.list', overriding mode 0644 (rw-r--r--)? y
 done!
 ~/Documents/Arduino_Projects/Tweak/arduino-1.8.1 $


Step 4. Open Arduino IDE.




Step  5. Go through Arduino UNO: https://www.arduino.cc/en/Guide/ArduinoUno

Step 6. Connect your Uno board with an A B USB cable; sometimes this cable is called a USB printer cable




The green power LED (labelled PWR) should go on.




Step 7. Open the Ardiuno IDE . Follow the path ( File -- > Examples -- > 01.Basics --> Blink ) and open the blink program.

Step 8. Click on Verify Button to Verify the program:



Step 9. On verification, we must receive message - Done Compiling in Status Bar:




Step 10. Let us now upload the program to the Ardiuno by clicking on the upload button:




Step 11. After upload we have received error message as follows:



Arduino: 1.8.1 (Linux), Board: "Arduino/Genuino Uno"

Sketch uses 928 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
To solve this error, I have referred the below blog:

http://arduino-er.blogspot.in/2014/08/arduino-ide-error-avrdude-seropen-cant.html

Step 12: To fix it, run the following commands at terminal:

sudo usermod -a -G dialout <<username>>
sudo chmod a+rw /dev/ttyACM0


 ~/Documents/Arduino_Projects/Tweak/arduino-1.8.1 $ sudo usermod -a -G dialout sashank
 ~/Documents/Arduino_Projects/Tweak/arduino-1.8.1 $ sudo chmod a+rw /dev/ttyACM0
 ~/Documents/Arduino_Projects/Tweak/arduino-1.8.1 $


Step 13. Upload Again. This time Upload is successful - we have received the following message: Done Uploading




This time received the message:

Sketch uses 928 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.


The blinker is blinking every 1 second. It was already blinking. Hence let us now modify the program for making it to blink every 3 seconds.


Step 14. Make the program to blink every 3 seconds:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);                       // wait for a second
}

We find that the orange LED in Arduino is now blinking every 3 seconds:




Success.




2 comments:

  1. it just can help only one time

    ReplyDelete
  2. Fantastic ... I had used the IDE on Windows 7 with no problems. Now I Have switched over to Linux Mint and I expected a few permission dramas! So good to get an answer that worked "straight out of the box".

    ReplyDelete