0
\$\begingroup\$
while(true) {
  movePlayer('upright', '10 * Time.deltaTime');
}

Here, an animation is done. No button or mouse click is done. Everything moves automatically.

How to make that in electronics ?

I know that with an human action, this can be done

[Mouse click]-------| \--------[Light pixel on (10,10)]

but... I want to automate this without any human action. How to do that ? For instance, if I want to light on, light off, light on, light off... several times, how to do that ?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Search for "blinking led". It should provide you with quite a few options. \$\endgroup\$
    – jcaron
    Commented Mar 27, 2020 at 12:35
  • 1
    \$\begingroup\$ user67097 - Welcome :-) Much, much more detail needs to be added to your question, in order to make this a valid question here. For example, you haven't mentioned your constraints, your skills (electronics, programming etc.), previous research etc. You mention animation, but then say light on, light off (which is just a blinking light) so your real question (and the reason why you added the "motor" tag) is unclear. Please read the tour and help center, including the page about on-topic questions. Then edit your question to improve it. Thanks. \$\endgroup\$
    – SamGibson
    Commented Mar 27, 2020 at 14:12
  • \$\begingroup\$ It's very weird youtube links are discouraged here as an answer. Whatever, I removed my answer -_- \$\endgroup\$
    – Sadat Rafi
    Commented Mar 28, 2020 at 7:40

1 Answer 1

1
\$\begingroup\$

For microprocessor development, "blink LED" is the "Hello World" program, the fist program a beginner should try to see if everything is working.

For an example watch https://training.ti.com/msp-exp430fr2433-launchpad-kit-blink-led.

In Mecrisp Forth for the MSP430 the code will be something like:

$0001 constant BIT0              \  define pin where led is connected
$0021 constant P1OUT             \  define port where led is connected

: P1.0_set_out ( -- )            \ Set P1.0 to output direction
  BIT0 P1DIR cbis!               \ clear bit
;

: toggle_P1.0 ( -- )             \ Toggles P1.0
  BIT0 P1OUT cxor!               \ xor bit
;

: delay( n -- )                  \ delay program by looping at 16 MHz
  0 do loop 
;

: ms ( n -- ) 
  0 do 16000 delay loop           \ wait n ms (replace later with threading)
;


: blink ( -- )
  P1.0_set_out
  begin 
    toggle 100 ms                \ toggle and wait 100 ms
  key? until 
;

Enjoy your first embedded program.

See also this Jeelabs article.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.