Skip to main content
guest
Join | Help | Sign In
Liberty BASIC Community Wiki Home
guest| Join | Help | Sign In
Liberty BASIC Community Wiki
  • Wiki Home
  • Recent Changes
  • Pages and Files
  • Members
  • Home
    • Liberty BASIC FAQ
    • Contests
    • Tutorials
    • Science
    • Shared Code
    • Tips
    • DLLs
    • PublicDomainSprites
    • Member Pages
    • Links
    • Sandbox

LEDDemo

Edit 0 2 …
  • 0 Tags
    • No tags
  • Notify
  • RSS
  • Backlinks
  • Source
  • Print
  • Export (PDF)
Older Version Newer Version

bshipps64 bshipps64 Feb 22, 2006 - "First created"

LED Demo

A simple demo illustrating the use of graphicboxes to represent state-changing LEDs.

 nomainwin 

WindowWidth = 150 : WindowHeight = 90

button #main.bSwitch, "Switch!", [switch], UL, 10, 12, 60, 25
graphicbox #main.gbGreen, 100, 10, 17, 17
graphicbox #main.gbRed, 100, 28, 17, 17

stylebits #main.gbGreen, 0, _WS_BORDER,0,0
stylebits #main.gbRed, 0,_WS_BORDER,0,0

open "LEDs" for window_nf as #main
main.isOpen = 1

#main "trapclose [exit]"
#main.gbGreen "down; fill buttonface; flush bkSeg; color black"
#main.gbGreen "backcolor darkgreen; place 8 8; circlefilled 7; flush greenSeg"
#main.gbRed "down; fill buttonface; flush bkSeg; color black"
#main.gbRed "backcolor red; place 8 8; circlefilled 7; flush redSeg"

wait

[exit]
if (main.isOpen) then close #main
end

[switch]
greenColor$ = word$("dark", abs(state)) + "green"
redColor$ = word$("dark", abs(not(state))) + "red"
state = not(state)

#main.gbGreen "delsegment greenSeg; redraw; backcolor "; greenColor$
#main.gbGreen "place 8 8; circlefilled 7; flush greenSeg"
#main.gbRed "delsegment redSeg; redraw; backcolor "; redColor$
#main.gbRed "place 8 8; circlefilled 7; flush redSeg"
wait
Help · About · Pricing · Privacy · Terms · Support · Upgrade
Contributions to https://basic.wikispaces.com/ are licensed under a Creative Commons Attribution Share-Alike 2.5 License. Creative Commons Attribution Share-Alike 2.5 License
Portions not contributed by visitors are Copyright 2018 Tangient LLC
TES: The largest network of teachers in the world
Turn off "Getting Started"
  1. Home
  2. ...
Loading...