Trying to use cuteduino as a remote control

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Trying to use cuteduino as a remote control

Postby lowfuyuan » Fri Feb 22, 2019 3:27 pm

Hi, I am trying to use my cuteduino to be a remote control for my robot via 433MHz transmitter and receiver. I attached pull-down resistor button to pin 1,2,3 and 4. pin 0 is used for the transmitter. I tested it and realise that the pin 3 button keep transmitting its message as if its pressed on. i tried pressing pin 4 button but nothing worked. pin 1 and 2 buttons is working normally. After doing a bit of research, I realise the issue could have been that pin 3 and 4 is used for USB comm. So i replaced my power supply from USB to battery but the issue remain. Could I know how to allow pin 3 and pin 4 be used a normal digital pin?

Here is the code that runs in the cuteduino:
CODE: SELECT_ALL_CODE
#include <VirtualWire.h>

void setup()
{
  // Initialize the IO and ISR
  vw_set_tx_pin(0);
  vw_setup(2000); // Bits per sec
  pinMode(1, INPUT);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  int button = 0;
}

void loop()
{
 if (digitalRead(1)) {
  send("001");
 }
 else if (digitalRead(2)) {
  send("010");
 }
 else if (digitalRead(3)) {
  send("011");
 }
 else if (digitalRead(4)) {
  send("100");
 }
 else {
  send("000");
 }
  delay(1000);
}

void send (char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}

Here is the code at the receiver end:
CODE: SELECT_ALL_CODE
#include <VirtualWire.h>

byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message

void setup()
{
  vw_set_rx_pin(A0);
  Serial.begin(9600);
  Serial.println("Device is ready");
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  vw_rx_start(); // Start the receiver
}

void loop()
{
  if (vw_get_message(message, &messageLength)) // Non-blocking
  {
    Serial.print("Received: ");
    for (int i = 0; i < messageLength; i++)
    {
      Serial.write(message[i]);
    }
    Serial.println();
  }
}
Attachments
cuteduino config.jpg
The arrangement of button
issue cuteduino.PNG
The serial monitor readings
lowfuyuan
Freshie
 
Posts: 4
Joined: Sat Oct 24, 2015 9:16 am

Re: Trying to use cuteduino as a remote control

Postby lowfuyuan » Fri Feb 22, 2019 3:50 pm

Hi , sorry I just found the solution for it.
It's from this link.
https://www.reddit.com/r/arduino/comments/28tjjz/need_some_help_with_digitalread_on_pin3_of/
Apparently there is a pull-up resistor in pin 3 and i just need to rewire it to be a pull up button and change my code.
I will just leave the post here and see what the admin will do.(Whether it will be deleted or not)
lowfuyuan
Freshie
 
Posts: 4
Joined: Sat Oct 24, 2015 9:16 am

Re: Trying to use cuteduino as a remote control

Postby ober » Mon Feb 25, 2019 7:29 pm

Good to know you manage to fix it!
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1440
Joined: Wed Apr 15, 2009 1:03 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 4 guests

cron