Use The Terminal To Test Arduino Is Working.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Use The Terminal To Test Arduino Is Working.
# 1  
Old 01-17-2013
Use The Terminal To Test Arduino Is Working.

Hi all...

(Apologies for any typos at all.)

This is a step by step _script_ to check if your Arduino is talking to your Linux or Macbook Pro computer using the Terminal...

It works on at least 3 Linux flavours and now the Macbook Pro...

I hope you find it useful as a simple check for your Arduino setup...

This is issued as Public Domain.

The "Test.pde" is the code to program the Arduino with.
My Arduino programming SW is old and I am aware that the "Test.pde" script will not compile on current Arduino programming SW. I am assuming you will know what to do with it...

Code:
A basic, terminal, test sequence to check that the Arduino Diecimila board is _talking_ to your computer.

Step by step testing inside a Linux , OR, Macbook Pro Terminal usage for the USB Arduino Diecimila Board...
Issued as completely Public Domain by B.Walker, G0LCU, 2011-2013.

Common to both systems:-
------------------------

1) Boot up to your Linux flavour or Macbook Pro as root, (or run in a root Terminal).
2) Temporarily disable any net access or use a stand-alone machine.
3) Plug in the USB Arduino board.
4) Open up a, (root), Terminal and clear the screen.
5) clear<RETURN/ENTER>

Linux flavours first:-
----------------------
6) Check that you have a device as ttyUSB?
IMPORTANT NOTE: Arduino boards are now detected as ttyACM? so although NOT tested this might still work...
If this is the case then replace ttyUSB? with ttyACM? below...

7) ls /dev<RETURN/ENTER>
NOTE:- ? above will probably be 0.
8) If ttyUSB0, (to 7), appears then carry on; otherwise ignore the remainder of this text.

NOTE:- Assuming the device is ttyUSB0 from now on, change below if needed to your ttyUSBx device.
9) Place a wire link between ANALOG 0 and the 3.3 V terminals, OR,
A potentiometer wired, one end to ground, GND, the other end to +5V and the wiper to ANALOG 0...

NOTE:- 'chmod' is probably not really needed but added for fullness!
10) chmod 666 /dev/ttyUSB0<RETURN/ENTER>

11) Set up the on board serial I/O to 9600bps and RAW data transfer for PCLinuxOS and Debian.
12) stty -F /dev/ttyUSB0 9600<RETURN/ENTER>
13) stty -F /dev/ttyUSB0 raw<RETURN/ENTER>

14) Now start printing characters to the screen...
15) cat < /dev/ttyUSB0<RETURN/ENTER>
NOTE:- The wire link characters will be from about 168 to 174 decimal allowing for bit error of the Arduino ADC.

16) Remove and replace the wire link from ANALOG 0 and GND or ANALOG 0 and 5 V too, OR,
A potentiometer wired, one end to ground, GND, the other end to +5V and the wiper to ANALOG 0...
17) Press 'Ctrl-C' to stop any characters being printed to the Terminal.
18) Unplug the USB Arduino board.
19) Power down the computer IF REQUIRED.

Now the Macbook Pro:-
---------------------
6) Now find the device name, mine is tty.usbserial-A7007cvs, yours will probably be much different...

7) ls /dev<RTETURN/ENTER>
8) If you have a new tty* note its name then carry on, otherwise ignore the rest of this text.
(I will use my device name for this example.)

9) Place a wire link between ANALOG 0 and the 3.3 V terminals, OR,
A potentiometer wired, one end to ground, GND, the other end to +5V and the wiper to ANALOG 0...

NOTE:- 'chmod' is probably not really needed but added for fullness!
10) chmod 666 /dev/tty.usbserial-A7007cvs<RETURN/ENTER>

11) Now start printing characters to the screen...
(The command stty does NOT work for this on the Macnook Pro so revert to the command cu instead.)
12) cu -l /dev/tty.usbserial-A7007cvs -s 9600<RETURN/ENTER>

13) Ctrl-C does not work so just close down the Terminal COMPLETELY.
14) Unplug tha Arduino board.
15) Power down the computer IF REQUIRED.

=============================================================

This is the "test.pde" code for the Arduino Diecimila board:-
-------------------------------------------------------------

/* Test.pde */
/* Using the Arduino as a DEMO single channel ADC for WinUAE. */
/* For use with AF2005 or greater. This is just demonstration code */
/* only and shows that I/O is possible through WinUAE by other means. */

/* Set up a variable 1 byte in size for basic analogue input. */
int analogue0 = 0;

void setup() {
  /* open the serial port at 9600 bps. This rate is used for purely */
  /* for simplicity only. */
  Serial.begin(9600);

  /* Set the analogue voltage reference, DEFAULT is 5V in this case. */
  analogReference(DEFAULT);
}

void loop() {
  /* Read the 10 bit analogue voltage on analogue input 0. */
  analogue0 = analogRead(0);
  /* Convert to a byte value by dividing by 4. */
  analogue0 = analogue0/4;

  /* Send to the Serial Port the byte value. */
  Serial.print(analogue0, BYTE);
  
  /* Delay 500 milliseconds before taking the next reading. */
  delay(500);
}

=============================================================

Enjoy finding simple solutions to often very difficult problems...

Bazza, G0LCU...


Last edited by wisecracker; 01-29-2013 at 05:50 PM.. Reason: Noticed that the "stty" line for the bps speed was 1200, now corrected to 9600...
This User Gave Thanks to wisecracker For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Arduino UNIX Time - Syncing Computer UNIX Time to Arduino Time with Python

Just finished a quick Python script to send the current unix time over to the Arduino from macOS, so in the absence of GPS or some other way to get the unix timestamp (epoch time) to the Arduino, I can get my macOS and Arduino UNO synced to within a second. Normally, when the Arduino starts... (9 Replies)
Discussion started by: Neo
9 Replies

2. Programming

Arduino-cli - Uploading to Unknown Chinese Arduino Boards using the Arduino Command Line Interface

In my further exploration of Arduino, today I decided to install the arduino-cli on my mac today. https://github.com/arduino/arduino-cli I followed the instructions for macOS but when I got to this part: arduino-cli board list I got the dreaded "Unknown" Fully Qualified Board Name... (1 Reply)
Discussion started by: Neo
1 Replies

3. UNIX for Advanced & Expert Users

Test -e not working as expected (by me)

I ran into the following and still do not understand entirely the rationale behind this. If someone could explain why things are as they are I'd be thankful. The following was tested on AIX 7.1 with ksh88, but i suspect that to be ubiquitous. In an installation routine i had to create a set of... (6 Replies)
Discussion started by: bakunin
6 Replies

4. Shell Programming and Scripting

Test function not working

i am writing the following snippet and cannot figure out why the variable measType remains 0. it should be 1 I also tried "\#analog" and '\#analog' in the test statement and it still doesn't work. What is going on? bash$ measType=0 bash$ read line < 2iconfig.ini bash$ echo $line #analog... (4 Replies)
Discussion started by: oahmad
4 Replies

5. Shell Programming and Scripting

String == isn't working in [[-test

Hi. I'm new to this forum, my English perhaps is not so good, but here is my question: In bash you can use ] for tests, and how I understand it the variable names should be expanded automatically. So this should give "yes": xx=hello $ ] && echo yes || echo no no # not giving "yes" These two... (2 Replies)
Discussion started by: 244an
2 Replies

6. UNIX for Advanced & Expert Users

if and test not working

All, I am getting error when run file check with test operator . Why is it showing the error if then echo 'file found' fi ksh: -r: unknown test operator I know i can use the below code to test the file but why the above is not working if test -r filename ... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

7. Shell Programming and Scripting

foreach loop working in terminal but not in the script

Hi, I am new here I have used the forums a long time to search for things they are very helpful. I have unfortunately used up all my resources (professors, grad students) and need some help. I have this very simple piece of code (using to isolate the problem) in a csh script: #!/bin/csh... (12 Replies)
Discussion started by: bflinchum
12 Replies

8. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

9. Solaris

How i test the UDP port is working?

Hi anybody know how to test out the UDP port working? cos UDP cannot use telnet to test... Sumemr (2 Replies)
Discussion started by: summerpeh
2 Replies

10. Shell Programming and Scripting

test command is not working

#!/bin/ksh size=3978132853 limit=100 if ;then echo exceeded limit fi This does not work though if i reduce 3978132853 to 397813285 it works any ideas and work around appreciated (SunOS 5.9 Generic_117171-02 sun4u sparc SUNW,Ultra-80 ) (2 Replies)
Discussion started by: zam
2 Replies
Login or Register to Ask a Question