help with serial communication

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i have a program that controls leds and i need a way to control them over serial. basicly i need a function that will take 4 ints only if there are any being sent so it can go back to the leds. can any one give me an example of how i would go about that? sorry if this question seems badly worded, I am not very good at explanining somthing that i envision in my head. Thank you. BTW I am using an attiny2313.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One way to approach this is to write a "command prompt" that is generated by the AVR and appears on a serial terminal on the PC. You then assign command letters/numbers to do various things in the AVR like '1' toggles on/off LED 1, '2' toggles on/off LED 2 and so on.

A command interface like this is always one of the first things I implement in a microcontroller so I can have a menu of test routines for invoking each individual module in the code - then higher level commands built on these things that tie the operation of several such modules together

The core of this is just a routine that prints a command prompt to the serial then waits for characters from it

Cliff