udamonic.com
  • Learn
    • What is a Scamp?
    • Order a Scamp
    • Getting Started
    • Learning Forth ... >
      • What is Forth?
      • Arithmetic
      • The Stack
      • Creating Words
      • Compilation Tricks
      • Comments
      • Characters and Strings
      • Constants, Variables and Values
      • Flow Control
      • Loops
      • Accessing Memory
      • Data Structures
      • Doubles, Triples and Quads
    • Extras... >
      • Starting up with turnkey
      • Formatting Text on Screen
      • Changing the Prompt
      • Delays and Tick Count
      • Processor Words
      • Temperature Sensor
      • Using the LED Array
    • Interfacing... >
      • Input/Output
      • Analog Input
      • Serial Communication
      • PWM
      • I2C Overview
      • I2C Commands
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Create
    • Adding LEDs
    • LED arc-welder effect
    • Measuring Temperature
    • Time Keeping
    • Model Train Control
    • FizzBuzz
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • Adding an RTCC
  • Resources
  • Consult
  • About
  • Contact

Create an Arc-Welder Effect using a LED
​

The motivation for this was a diorama display that featuring a model arc welder. It used an Arduino to drive the LED. I decided to do a version in Forth to show how easy it is.
​
The demo code using the Scamp's onboard status LED is:
: welderdemo
  begin
     random $f00 u/ for
        random $ff u/ ms ledon
        random $ff u/ ms ledoff
     next
     random $ff u/ ms
  key? until 
;

Use an External LED
​

See the page on adding a LED for an understanding of the basic LED circuit. Choose a blue/white and connect it to pin 1 on your Scamp. Place the LED anywhere on your layout or diorama, where you want the arc-welding effect to be.
Let's assume we have connected the external LED to pin 1 of the Scamp. To control it, we need to make pin 1 an output.

Modifying the code to use an external LED:
: welder
  1 output
  begin  
    random $f00 u/ for
       random $ff u/ ms 1 set
       random $ff u/ ms 1 clear
    next
    random $ff u/ ms
  again
;
Picture
This word will repeat forever. To make this word run at startup:
' welder is turnkey

Site powered by Weebly. Managed by Hostwinds
  • Learn
    • What is a Scamp?
    • Order a Scamp
    • Getting Started
    • Learning Forth ... >
      • What is Forth?
      • Arithmetic
      • The Stack
      • Creating Words
      • Compilation Tricks
      • Comments
      • Characters and Strings
      • Constants, Variables and Values
      • Flow Control
      • Loops
      • Accessing Memory
      • Data Structures
      • Doubles, Triples and Quads
    • Extras... >
      • Starting up with turnkey
      • Formatting Text on Screen
      • Changing the Prompt
      • Delays and Tick Count
      • Processor Words
      • Temperature Sensor
      • Using the LED Array
    • Interfacing... >
      • Input/Output
      • Analog Input
      • Serial Communication
      • PWM
      • I2C Overview
      • I2C Commands
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Create
    • Adding LEDs
    • LED arc-welder effect
    • Measuring Temperature
    • Time Keeping
    • Model Train Control
    • FizzBuzz
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • Adding an RTCC
  • Resources
  • Consult
  • About
  • Contact