I have the following items:

So far, I've been able to write output to data pins. Now I want to attach a sensor, but I need to see the sensor output on my computer.

I'm trying to make the micro-controller write 'K' character to TX pin and as far as I understood I should be able to connect to /dev/ttyACM0 using putty or screen from my Linux computer and see the output, but when I run the following commands, I get no output, I also tried ttyACM1, ttyACM2 but still nothing:

 putty /dev/ttyACM0 -serial 9600


 screen /dev/ttyACM0


#define F_CPU     1600000UL
#define BAUD      9600
#define BRC       ((F_CPU/16/BAUD) - 1)

#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>

int main( void ) 
    UBRR0H = (BRC >> 8);    
    UBRR0L = BRC;

    UCSR0B = ( 1 << TXEN0 );
    UCSR0C = ( 1 << UCSZ01 ) | ( 1 << UCSZ00 );

    while( 1 )
        UDR0 = 'K';

    return 0;


CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=atmega$(MEGA)

program : $(TARGET).hex
    $(PROG) -c avrispv2 -p m$(MEGA) -P /dev/ttyACM0 -e
    $(PROG) -c avrispv2 -p m$(MEGA) -P /dev/ttyACM0 -U flash:w:$(TARGET).hex

%.obj : %.o
    $(CC) $(CFLAGS) $< -o $@

%.hex : %.obj
    $(OBJ2HEX) -R .eeprom -O ihex $< $@

clean :
    rm -f *.hex *.obj *.o

When I run the micro-controller I see the TX LED blinking, so I'm guessing the micro-controller is actually sending the data, but I'm just not reading it correctly on the computer side. Any suggestions?

  • \$\begingroup\$ TX on the micro = RX on the programmer, and vice versa. Is this how you have it hooked up? \$\endgroup\$ – Cheibriados Jul 20 '16 at 19:46
  • \$\begingroup\$ @Cheibriados I placed the micro-controller into the Arduino Uno 'case' and connected the cable from USB programmer to Arduino schematic (so I don't have to do the wiring on the breadboard) like this: yourduino.com/sunshop2/images/products/large_114_TinyISP-3.jpg but I'm using different programmer \$\endgroup\$ – K666 Jul 20 '16 at 19:53
  • \$\begingroup\$ @Cheibriados Do I need to flip the TX/RX wires in the cable to get this working? \$\endgroup\$ – K666 Jul 20 '16 at 20:51

Turns out, even though I tried this device before, now suddenly I see output:

cu -l /dev/ttyACM2 -s 9600

but before that I ran

echo '12' > /dev/ttyACM2

As far as I understood, I needed to send two sequential bytes to open the connection.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.