🎨
MadMachine-Examples
  • Introduction
  • About our project
  • Getting Started
  • Tutorial
    • What is SwiftIO
    • How to use IDE
    • Libraries
    • MM SDK
  • Built-In Examples
    • GettingStarted
      • Blink
      • ReadDigitalInput
      • ReadAnalogInput
      • PWMBrightnessControl
    • SimpleIO
      • ButtoncontrolLED
      • BlinkAnalogIn
      • BlinkTimer
      • BrightnessAnalogIn
      • Debounce
      • LEDsBrightnessControl
      • PWMSoundOutput
      • PWMMelody
    • AdvancedIO
      • ILI9341
      • LCD1602
      • MidiPlayer
      • PCA9685
      • SHT3x
      • SSD1315
    • Challenge
      • LCDFamily
      • RobotArm
      • Tetris
    • MakerKit
      • Mission 01 Blink
      • Mission 02 RGB LED
      • Mission 03 Push Button
      • Mission 04 Potentiometer RGB
      • Mission 05 Buzzer
      • Mission 06 Seven Segment Display
      • Mission 07 DC Motor
      • Mission 08 Servo Motor
      • Mission 09 LCD
      • Mission 10 Humiture Sensor
  • Library Reference
  • FAQ
Powered by GitBook
On this page
  • What you need
  • Circuit
  • Tips
  • Code
  • Video
  • See Also
  • References

Was this helpful?

  1. Built-In Examples
  2. MakerKit

Mission 01 Blink

What you need

Circuit

Tips

Code

/*
  Mission1 Blink RGB LED

  The blue LED will flash on for 1 second, then off for 1 second.

  The circuit:
  - Use the onboard RGB LED.
  - Note: SwiftIO have an on-board RGB LED you can control.
    The onboard LED will be on when the value is set to false.

  created 2019
  by Orange J

  Try to change the RGB Led’s color to Red, Green, and Blue. 
  Add a blinking loop and see what will happen. This example code is in the 
  public domain. Visit madmachine.io for more info.
*/

import SwiftIO


// initialize the blue LED
let led = DigitalOut(Id.BLUE)

while true {
     // The code here will run all the time.

     // Set Blue LED off
     led.write(true)
     sleep(ms: 1000)    // Interval of LED blink (milliseconds)

     // Set Blue LED on
     led.write(false)
     sleep(ms: 1000)
}

Video

See Also

References

Last revision 2020/09/10 by Johnson

PreviousMakerKitNextMission 02 RGB LED

Last updated 4 years ago

Was this helpful?