# Can't write to serial from microcontroller

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


OR

 screen /dev/ttyACM0


Code:

#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';
_delay_ms(1000);
}

return 0;
}


Makefile:

CC=/usr/bin/avr-gcc
MEGA=328p
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=atmega$(MEGA) OBJ2HEX=/usr/bin/avr-objcopy PROG=/usr/bin/avrdude TARGET=serial 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?

• TX on the micro = RX on the programmer, and vice versa. Is this how you have it hooked up? – Cheibriados Jul 20 '16 at 19:46
• @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 – K666 Jul 20 '16 at 19:53
• @Cheibriados Do I need to flip the TX/RX wires in the cable to get this working? – K666 Jul 20 '16 at 20:51

cu -l /dev/ttyACM2 -s 9600

echo '12' > /dev/ttyACM2