Go Down

Topic: Strange Serial Port Problems (Read 582 times) previous topic - next topic

FelixK

Hi,

I'm writing a simple arduino program to light up leds when a certain character comes in on the serial port. Everything on the Arduino side works fine.

Then i wrote a ruby app to talk to Arduino on the serial port. Very simple code:

Code: [Select]

sp = SerialPort.new "/dev/tty.usbserial-A6008mdp", 9600, 8, 1, SerialPort::NONE
sp.write "y\r\n"


This code for some reason only works when I have the serial monitor in the Arduino IDE open. If I exit the IDE it doesn't work...i see the RX light on the board light up, and the the LED on pin 13 lights up, and nothing.

Any ideas why this could be happening? I'm running on Mac OS X Snow Leopard.

Thanks,
Felix

LMI

I am guessing, but as now one else is helping, how about this:
I had problems with RESET-EN coming active. When I started my pc or VB ide, Arduino changed to programming state. But this was different in two pc's. Maybe this can happen with Macs too.

I had to cut the jumper in RESET-EN track. Now I cant program Arduino before I solder the jumper again, but now Arduino works with the program it has.

needle

Hi

i've been busy for some time now with serial, ruby and arduino. i got it working, but there's a small problem it has a strange delay of about 2 seconds... so if you want to put pin 12 on for 3 secondes you should give a parameter of 5

i used the PhysicalPixel example (changed the output to 12)

ruby code:




require "serialport.so"

if ARGV.size < 1
 STDERR.print <<EOF
 1st_serial_port 2nd_delay_in_seconds
#example: ruby serialH7.rb /dev/tty.usbserial-A6008i1S 5
EOF
 exit(1)
end

sp = SerialPort.new(ARGV[0], 9600, 8, 1, SerialPort::NONE)

 delay = ARGV[1].to_i
  timer = 0
     
     while TRUE do
      sp.write "H\r\n" #sets pin 12 to HIGH
       puts timer
       timer += 1
       sleep(1)
      break if timer == delay
    end
   
     sp.write "L\r\n" #sets pin 12 to LOW
    sp.close
  puts      



any help would be welcome

LiMiT

Why not put the timing/LED program on the Arduino and just have the Arduino react to the string you are sending over serial?

Go Up