how use pin rx tx to on off ( high low ) an relay or led

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

Hellow

how use pin 0 and pin 1 ( rx tx ) to be pin 0 and 1 to power on an relay or led ?

I want transforme it pin rx tx in pin digital 1 and 2.

I want put an button in rx and relay in tx.

do you can send an basic code to test here ?

 

Last Edited: Thu. Jul 19, 2018 - 05:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You've posted this in the Atmel Studio forum; does this mean that you are not using the Arduino framework?

 

As far as the AVR is concerned, these pins can just be used as standard GPIO - no differently from any other GPIO pins.

 

However, the UART Rx and Tx functions are far more "valuable"  - so why would you "waste" them as just standard IO?

 

When using anyone else's board design - Arduino or anything else - you should check the board schematic to see if the board has anything else connected to particular pins

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, you cannot just put a relay onto any microcontroller pin like that!

 

EDIT

 

Well, OK, you can - it just won't last very long.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Jul 19, 2018 - 01:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

D0,D1 are used in the Arduino Uno as the TX RX pins and so are used to upload new sketches, so should not be used for other things.

If you have used all the other Dx pins, you can use any Analog pin A0-A5 as digital pins too.

To add a relay, connect it like this:

 

 

Jim

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

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

In those arduino's the "rx" pin is hard wired to the output pin of a USB <==> Serial chip. Normally a CH340.

If you want to use that pin as an output, then you have to cut the trace from the USB <==> Serial chip, or desolder and lift the right pin ( See arduino schematic for that).

 

You will also loose serial communication with the PC, and thereafter can only program your AVR with an external programmer.

 

A common way to make more output pins on an "arduino" is to use a shift register (For example 74hc595).

Paul van der Hoeven.
Bunch of old projects with AVR's:
http://www.hoevendesign.com