Squirrel code to write a pins state to LCD

Non programmer here so I will need a bit of help.

Below I have found a bit of code to write a simple message to my LCD screen using the instructions I found here.

http://www.instructables.com/id/Wiring-and-programming-an-Electric-Imp-with-an-LCD/

I’ve worked out, that what every is in the message section will appear on screen.

hardware.uart12.configure(9600, 8, PARITY_NONE, 1, NO_RX);

CharactersInLCD <- 16;
Message <- “your message”;

I think I can use this code and some how change 1 to mean on and 0 to mean off

led <- hardware.pin1;
led.configure(DIGITAL_OUT);

led.write(1);
server.log(led.read());
led.write(0);
server.log(led.read());

Then some how take the results and put them
in the Message portion of the code for my LCD.

Am I on the right course or not, Please advise.

That’s broadly right, @chakahamilton, yes. I haven’t looked at the code you’re referring to, but that’s essentially it: read data then display feedback on the screen accordingly.

The exact code will depend on the data you’re trying to read; you’ll want to set led.configure() to DIGITAL_IN so you can - for example - get it to read a button. You read it with led.read(): when the value is 1, you send one string of text to the LCD via Message; when it’s 0, you send a different string or clear the screen.

I have a problem in controlling th imp remotely (ie) i see many videos in which people control the imp through their mobile phones using imp (both in android and ios) but the thing is how to do that or is there any ways to program in the agent window through which we create buttons in server side to control the imp?

If you can develop iOS or Android apps, @RAga, it’s easy to control imps via agents: you use the mobile OS’ in-built URL connection tools to send HTTP requests to the agent’s URL. You will need to configure your agent to respond to these requests and to pass on control and/or data-request messages to the imp.

Talking to the agent URL can also be achieved using a web browser and standard web programming techniques.

Check out The interactive imp to learn how to manage communication between app, agent and device.

If you’re an iOS user, I have an app foundation you can use to build your own control app. It’s on GitHub here

@RAga It is pretty easy to use jQuery in the agent to make a web control. If you use an iPhone, also check out Little Devil and Pitchfork on the app store.

I have a few examples on my GitHub page.

@smittytone and @jwehr thank you guys :slight_smile: let me try it :slight_smile:

@smittytone I wont be using a button. I will be using the agent code. In anycase how do i take the state of the Led save it then pipe it into the message field. (Again not a programmer so my terminology will be off) Do you have a code example?

Since you’re setting the state of the LED, you know what that state is - you don’t have to check the LED to find out. So you can write in your device code:

led.write(1); server.log("LED on"); led.write(0); server.log("LED off");

To learn how to send messages from the agent to the device, possible to set the text that displays on the LCD, check out The Interactive imp. This also covers sending info from the device to the agent.

@smittytone i’ll read through this and give it a whirl, thanks for your help.

Ive had no success, anyone out thee have an example snippet I can draw upon?

Wow, 4 months of no helpful hints for beginners? No problem I completed the project in Arduino where the community was very helpful.

Sorry to hear you got stalled with the imp @chakahamilton - but I’m glad you managed to finish your project!

The Electric Imp community is much younger and smaller than the Arduino community, so there’s less ready made code (and resources in general) floating around.

It’s something we’re working on - and something that is improving, but early communities are hard!