Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Sunday, August 30, 2020

Wireless Hello World

That means - you press a (possibly virtual) button and an LED lights up someplace else.

https://www.youtube.com/watch?v=OhnxU8xALtg

 Arduino, HC-05 bluetooth module, breadboard, processing, sketch, blue control Android app

Google search that was useless : "what is the easiest way to get a notification on your phone from a device at home?"

Another one "do you need a subscription to get notifications from home kit devices?"

Tuesday, August 25, 2009

Sub-Microsecond Delays with Arduino

It's possible!

The Arduino delayMicroseconds() function creates the shortest delay possible from within the Arduino language. The shortest delay possible is about 2 us (microseconds). Not true - I've tried and the shortest is about 4.5 us.

For shorter delays use assembly language call 'nop' (no operation). Each 'nop' statement executes in one machine cycle (at 16 MHz) yielding a 62.5 ns (nanosecond) delay.

__asm__("nop\n\t");

__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t"); \\ gang them up like this

Really, why not a loop?

Dat's vy :

If you write a C loop, it will change into NOP instructions and compares/increments for counters. So your timing will be off. Unrolling loops is a standard practice to get rid of the compares/increments.


Verdict :

You also need to know stuff on this page :

http://arduino.cc/en/Reference/PortManipulation

If you use digitalWrite(), a single write takes 4.5 us to execute. But using

PORTB = PORTB & B11101111;
to set pin 12 low, with no intentional delay, I see a delay of about 400 ns. So much for being able to get 62.5 ns! If I put in 4 NOPs, I get the delay increasing to 620 ns. So we're on!