BRLAB DOCS
HomeTutorialsHardware
IoT Relays with Particle and Blynk
IoT Relays with Particle and Blynk
  • Introduction
  • Getting Started
    • What You Will Need
    • Claim Your Particle Device
    • Setup Your Blynk Account
  • Creating the Web Dashboard
    • Template
    • Data Streams
    • Widgets
    • Widget Settings
    • Finished Web Dashboard
  • Creating the Mobile App
    • Blynk.App
    • Widgets
    • Widget Settings
  • The App Code
    • Particle Web IDE
    • Blynk Library
    • Writing The Code
      • Comment Header
      • Define Blynk Objects
      • Define Global Variables
      • Void Setup()
      • Void Loop()
      • BLYNK_WRITE()
    • Application Code
    • Control The World Around You
  • Resources
    • Blynk Documentation
    • Particle Documentation
Powered by GitBook
On this page
  1. The App Code
  2. Writing The Code

Void Setup()

This section of the code is executed once at startup. This is were you can initialize code or just run a task once when the device first powers on.

For this application we will define the pin mode of each I/O, set the default relay state, and connect to the Blynk cloud.

void setup()
{
    for(int i=0; i<4; i++){ 
    // for loop for setting each I/O pin mode as an output
        pinMode(relayPins[i], OUTPUT);
        digitalWrite(relayPins[i], LOW);
    }
    delay(5000);
    Blynk.begin(auth); // connect to blynk cloud using auth token
}
PreviousDefine Global VariablesNextVoid Loop()

Last updated 2 years ago