AgTalk Home
AgTalk Home
Search Forums | Classifieds (189) | Skins | Language
You are logged in as a guest. ( logon | register )

Anybody here messing with Arduino stuff?
View previous thread :: View next thread
   Forums List -> Computer TalkMessage format
 
tedbear
Posted 1/17/2018 11:58 (#6511676 - in reply to #6507343)
Subject: Simple Phone example


Near Intersection of I-35 & I-90 Southern Mn.
Below I have a three pictures of a simple example using my iPad (iPhone would look the same but smaller) with an Arduino Uno and a shield called 1Sheeld. This example show how an LED can be turned ON with a momentary switch or through the phone app.

The code could have been shorter by using an OR in the If statement. But by doing it this way I could just paste the IF block in and modify it.

First pic shows the board with momentary swith and LED. LED is off because neither the push button or the app is pushed.The switch is connected with a pull down resistor, it is an input on Pin 3. The LED is connected as an output on pin 13. The next picture shows the light on by pushing the momentary. The last picture shows the app on the iPad. Pushing the Red button causes the LED to light and releasing causes the LED to go out. By using this with a relay, it could act as a garage door remote. The relay could be connected across the terminals of the opener like a simple push button.

One could cycle the door either by using the phone or tablet with the app or the push button on the bread board. A possible limitation which is maybe good from a safety standpoint is that only one device can communicate with the Shield at a time. If I have the iPhone running the App for the push button, I'm not able to get the iPad to communicate and make the bluetooth connection. When the iPhone gets out of range, the connection is broken and the other device can communicate. From a safety standpoint such as cycling a door or starting some machinery this is probably a good thing.

Here's the sketch which is a 1Sheeld example with my additions for the momentary switch-----------------

/*
Push Button Shield Example expanded by Ted to watch for a momentary switch.

This example shows an application on 1Sheeld's push button shield.

By using this example, you can turn on the LED on pin 13
when you press the app's push button.

OPTIONAL:
To reduce the library compiled size and limit its memory usage, you
can specify which shields you want to include in your sketch by
defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define.

*/

#define CUSTOM_SETTINGS
#define INCLUDE_PUSH_BUTTON_SHIELD

/* Include 1Sheeld library. */
#include

/* A name for the LED on pin 13. */
int ledPin = 13;
int sw =3;

void setup()
{
/* Start communication. */
OneSheeld.begin();
/* Set the LED pin as output. */
pinMode(ledPin,OUTPUT);
pinMode (sw,INPUT);

}
void loop()
{
/* Always check if the push button is pressed. */
if(PushButton.isPressed())
{
/* Turn on the LED. */
digitalWrite(ledPin,HIGH);
}
else
{
/* Turn off the LED. */
digitalWrite(ledPin,LOW);}

int state=digitalRead(sw);// check board switch

if(state==HIGH)
{
/* Turn on the LED. */
digitalWrite(ledPin,HIGH);
}
else
{
/* Turn off the LED. */
digitalWrite(ledPin,LOW);
}

}




Edited by tedbear 1/17/2018 14:07




(IMG_0060[1].JPG)



(IMG_0061[1].JPG)



(IMG_0063[1].JPG)



Attachments
----------------
Attachments IMG_0060[1].JPG (219KB - 248 downloads)
Attachments IMG_0061[1].JPG (189KB - 257 downloads)
Attachments IMG_0063[1].JPG (161KB - 271 downloads)
Top of the page Bottom of the page


Jump to forum :
Search this forum
Printer friendly version
E-mail a link to this thread

(Delete cookies)