Pages: [1]   Go Down
Author Topic: Standard Firmate with blink  (Read 687 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I need to access switches and control LEDs from within VB.net.

So got an Arduino Nano.

I am a totally new Arduino user, and so am still a bit ignorant.

I had thought I would use the Serial Control, and create my own sketch.
I have got switches to send messages to the Serial Monitor, and I can send triggers from the serial monitor to switch LEDs off and on.

I was particularly proud of myself, when I managed also to incorporate a blink loop, so that the LED could be set to flicker when triggered on.

But then I found Firmata.
This would seem to take a lot of the programming work away, giving a control that will drop straight into VB.net.

So I tried this, and sure enough, I can control LEDs, and read switches using the Firmata Standard sketch.

But...

I can't even vaguely work out how to use Firmata to set the LED not to just stay on constantly, but to blink/flicker at a preset rate.

I thought I might be able to take my blink routine from the original sketch, and stick it somewhere in the Standard Firmata sketch to control the flicker on the digitalWrite line.

However, I can't even find a digitalWrite line in the Standard Firmata sketch.
I can't find any line which is switching on the LEDs.
So I have no idea how to make an LED blink.

Is it possible? Is it complicated? Is it worth it?

Or should I go back to my original idea of coding my own sketch and communicating via Serial?

Any help gratefully received.

Thanks.

Paul

Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 638
Posts: 50304
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The whole idea with firmata is to turn control of the Arduino over to the PC. It is then up to the PC to make the LED blink, by turning it off and on at the appropriate time.

VB has a timer object. Use that to trigger a routine that sets the appropriate pin HIGH or LOW as required.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you.
That makes sense.

Since the VB.net program is going to be doing a lot of other things, I wanted to reduce the processing burden as much as possible.
That's why I liked the idea of the blink timing being done by the Arduino.

I wonder which is the more efficient way of doing it - using the Firmata protocol, with VB.net controls, and put a timer in the program, or do it via Serial control and put the timer on the Arduino?

Paul


Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 638
Posts: 50304
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Everything that the Arduino does, with the Firmata sketch loaded, is done be sending specifically formatted messages to the Arduino, via the serial port.

What message in the firmata protocol would you send to blink the LED?

The answer is that there is none, so you'd need to modify a lot of stuff, in the sketch and in the firmata library that the sketch links and in all the other libraries that reference firmata - for Processing and VB to mention just two - to add a blink message.

Of course, you are not required to use firmata. You can develop your own protocol, as you were doing.

On the other hand, the PC has lots more capacity to manage a timer to blink the LED than the Arduino does - not that blinking an LED is resource intensive, mind you.

Perhaps if you said something about what else the VB app is going to be doing, and how the VB app is being developed/deployed. VB is an interpreted language, usually, so there are faster languages, that will leave the computer more time to blink an LED for you.
Logged

Pages: [1]   Go Up
Jump to: