AutoArduino Turn a LED on or off

Use AutoArduino to simply turn a LED on or off

  1. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    joaomgcd submitted a new AutoApps project:

    Turn a LED on or off - Use AutoArduino to simply turn a LED on or off

    Read more about this project...
     
  2. wastubbs

    wastubbs New Member

    Joined:
    Sep 13, 2016
    Messages:
    4
    Likes Received:
    0
    Hi João,

    I've got an Arduino Uno with an HC-06 installed on it and have successfully written tasks to connect and disconnect from AutoArduino! My current problem is trying to write to pin 3, I don't seem to be able to toggle it or set it to high on command from AutoArduino. I've confirmed pin 3 is hooked up properly in my Sketch by uncommenting the block you see below. Can you spot any issues with it? Any additional information I can provide you?

    I've tested with a multimeter as well and confirmed the 1 second blink commented out does send 5v out through pin 3, but doesn't respond when send TOGGLE pin 3 or HIGH pin 3 from AutoArduino.


    Code (Text):
    #include <SoftwareSerial.h>
    SoftwareSerial BT(10, 11);
    // creates a "virtual" serial port/UART
    // connect BT module TX to D10
    // connect BT module RX to D11
    // connect BT Vcc to 5V, GND to GND

    int ledPin = 3;                 // LED connected to digital pin 3

    void setup()
    {
      // set digital pin to control as an output
      pinMode(13, OUTPUT);
      // set the data rate for the SoftwareSerial port
      BT.begin(9600);
      // Send test message to other device
      BT.println("Hello from Arduino");


      pinMode(ledPin, OUTPUT);      // sets the digital pin as output

     
    }
    char a; // stores incoming character from other device
    void loop()
    {

    //// This is just to test that pin 3 is working from code.
    ////
    //      digitalWrite(ledPin, HIGH);   // sets the LED on
    //      delay(1000);                  // waits for a second
    //      digitalWrite(ledPin, LOW);    // sets the LED off
    //      delay(1000);                  // waits for a second

      if (BT.available())
      // if text arrived in from BT serial...
      {
        a=(BT.read());
        if (a=='1')
        {
          digitalWrite(13, HIGH);
          BT.println("LED on");
        }
        if (a=='2')
        {
          digitalWrite(13, LOW);
          BT.println("LED off");
        }
        if (a=='?')
        {
          BT.println("Send '1' to turn LED on");
          BT.println("Send '2' to turn LED on");
        }  
        // you can add more "if" statements with other characters to add more commands
      }
    }
     
  3. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    You need to install the sketch that's linked in the google play store description :) Can you try with that one please? Thanks
     
  4. wastubbs

    wastubbs New Member

    Joined:
    Sep 13, 2016
    Messages:
    4
    Likes Received:
    0
    I will do that, thank you! Sorry I didn't read the directions more closely!
     
  5. wastubbs

    wastubbs New Member

    Joined:
    Sep 13, 2016
    Messages:
    4
    Likes Received:
    0
    João,

    Which pins should my HC-06 RXD and TXD be mapped to? I think that might be my current issue...

    With the pins.ino sketch loaded in my Arduino, the HC-06 does still power up and accept a connection from Tasker/AutoArduino, but I think I can do that no matter what sketch is loaded..

    Here are a few more observations I've made.
    • With pins.ino loaded, pin 3 is outputting 1.5v, so I've switched my LED to pin 6. It looks like pins.ino does some special stuff with #3!
    • There's mention of Ethernet control in pins.ino, but no libraries that explicitly mention Bluetooth. Am I missing a component?
    • My HC-06 is wired as follows from a previous sketch, but I don't know where to map that in pins.ino
      • RXD -> 10
      • TXD -> 11
      • 5V -> VCC
      • GND -> GND
    Thanks, João!
     
  6. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
  7. wastubbs

    wastubbs New Member

    Joined:
    Sep 13, 2016
    Messages:
    4
    Likes Received:
    0
    Ah HA! That did it, thank you, João!

    Seems like when I tell the pin to go "HIGH" it's outputting 1.5V, but I can work with that. I will turn on 2 pins at once to get the voltage I need.

    EDIT: Disregard - NONE of the sketches I sent to my Duo were taking after I wired RXD -> TX and TXD -> RX (including pins.ino) because my uploads were erroring out. I didn't notice it happening because when the lights on the Duo blinked off & back on, I was incorrectly assuming the Duo had been updated! Here's the error I got;

    Code (Text):
    avrdude stk500_getsync(): not in sync resp=0x30
    This can happen any time something is pinned to 0 (RX). I unhooked this pin to perform the upload, then plugged it back in, and hey hey, it works a treat.

    Thanks, João!
     
    Last edited: Sep 15, 2016
  8. srccjcathome

    srccjcathome New Member

    Joined:
    Jan 21, 2017
    Messages:
    3
    Likes Received:
    0
    I am having difficulty connecting my phone to my arduino with the usb/OTG adapter. I've tried a Galaxy S7 and Galaxy S4, both of which support USB OTG. I'm using an older Arduino (Arduino Duemilanove). Is that an issue, should I buy an Uno instead?
    I launch Autoarduino and try to add an arduino, I select USB, and get "Arduino not found"
    The board is loaded with the sketch that is linked in Google play with the Autoarduino app.
    Any advice you could offer would be greatly appreciated.
     
  9. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    You're now the second person that has issues with Samsung devices and USB/OTG. :( I'm starting to think it's some specific issue with samsung. Sorry, I'll try to figure something out.
     
  10. srccjcathome

    srccjcathome New Member

    Joined:
    Jan 21, 2017
    Messages:
    3
    Likes Received:
    0
    Update: I just bought a new Arduino Genuino Uno and tried again with my samsung phones using the USB OTG adapter. This time it worked like a charm. After that test was successful, I disconnected the USB and I hooked up a new HC-06 bluetooth adapter exactly as you described in your post above (post #6). This also worked perfectly.
    I guess my old Duemilanove board just wan't up to the challenge. Anyway, problem solved.
    Thanks a lot for creating these awesome apps. I'm going to have a lot fun with this.
     
  11. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Awesome! :D Glad it works now!
     
  12. Poloace

    Poloace New Member

    Joined:
    Feb 7, 2017
    Messages:
    11
    Likes Received:
    1
    Hello Joao,

    like above comment.

    I have Arduino uno SMD edtion and normal and both have the same problem.
    I am trying to use autoarduino via OTG, I have tried on My HTC M9 and on a Samsung Galaxy ace, and another phone running a more vanilla version of Android. I have detected the arduino in some other apps but always get nothing connected. I wondering if it is to do with USB status. I am using the code shared on Git hub exactly as posted.
    Do you have any tips or ideas for me to get this working. I only need the OTG USB operation.

    Is there anything I can suggest, I really need to have 4 external triggers into Tasker, and the arduino route would be perfect.
     
  13. Poloace

    Poloace New Member

    Joined:
    Feb 7, 2017
    Messages:
    11
    Likes Received:
    1
    I have installed a USB host controller app, and that can clearly detect the Arduino, my phone HTC M9 is running Android 6 / HTC Sense Version 7.
    I cannot detect it in the App, is the code on github just for ethernet use or should that work ok for OTG. I look forward to your advice.
     
  14. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Hi there. Does the app not show a prompt asking you to allow USB access when you try to add the Arduino via USB? Thanks!
     
    Poloace likes this.
  15. Poloace

    Poloace New Member

    Joined:
    Feb 7, 2017
    Messages:
    11
    Likes Received:
    1
    Hello Joao, Thank you for the reply, it does not ask for access it just states "Arduino Not Found PLease connect your Ardunio through USB and try again". The same message is received when it is un plugged. I do have options on the USB connection type on the HTC and wondered if this is effecting, as if it was not connected. I have been successful with another app (Arduino Android Otg, that allows me to turn on and off an LED just via serial comms, and exactly the same OTG cable and arduino, it uses and a very simple serial code but obviously it does not have your awesome tasker itegration. So I guess it must be something to do with your app or the ardunino code with the extra ethernet features that is not working on my phone. I tried getting Bluetooth running but currently have issues with the Bluetooth modules not pairing to me phone so I cannot as yet try them with the. I have tried stripping back the Arduino code but no luck, i was unsure if I should set ethernet to = false or something.
    As I mentioned in my email to you about the same problem I am happy to give you a nice donation if you help get this working for me.
     
  16. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    The problem is not with the .ino file since that doesn't even come into effect until the Arduino is connected to the phone. The problem is with the code in the android app that is used to connect via USB that for some reason is not compatible with your phone :( It works fine on all of my phones so it must be something specific to your models or Android versions that I'm missing, sorry. I'll try to figure it out..
     
  17. Poloace

    Poloace New Member

    Joined:
    Feb 7, 2017
    Messages:
    11
    Likes Received:
    1
    Please could you confirm the working phones and I will pop out a buy a different phone, and give it a try. I did try it on some other old android phone.
     
  18. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    9,479
    Likes Received:
    806
    Oh, please don't buy another android phone because of this! What if it ends up not working any way? That would be a lot of money wasted, right?
    Anyway, I tried it on a Nexus 6 and LG G4 and it worked on both...
     
  19. Poloace

    Poloace New Member

    Joined:
    Feb 7, 2017
    Messages:
    11
    Likes Received:
    1
    Thanks do you know if any of the older samsung phones work with it?
     
  20. Poloace

    Poloace New Member

    Joined:
    Feb 7, 2017
    Messages:
    11
    Likes Received:
    1
    I managed to get hold of a LG G4, so I will you know how I get on with it, if anyone esles using autoArduino coudl also share with me their phone and OTG setup that would be great. I have also ordered some more Bluetooth modules to see if I can get that working also.
     

Share This Page