FourBoard Basic Setup
the FourBoard1.1 lighting 4 incandescent bulbs at independent brightness


This example is used to test components on the FourBoard1.1 as a starting point for any application.
The video shows FourBoard and Arduino Nano programmed with FourBoardBasicSetup.ino
Powered by a 12V battery, a 21W incandescent bulb is connected to each power channel.
The dials adjust the duty cycle of each PWM output at the default frequency of each pin.
Every button press and hold lights the LED on PIN13 to confirm response.

Seen here, the CH+/VIN link is shorted with a wire, which is suitable for delivering power within the 50W, 36V, 3A channel limit.
FourBoard1.1 Diagram Card (PDF 398 KB)
All 4 channels can be combined in parallel to power a single device up to 200W or 12A when coded to switch the combined MOSFET pins in unison.

Inductive loads within limits are handled appropriately by the IRF540 MOSFETs repetitive ratings,
 but caution must be used with parallel, capacitive, or large in-rush current loads,
 the Nano voltage regulator cannot handle excessive voltage change caused by exceeding channel limits.
In such configurations, a 100-500 Ohm resistor on the CH+/VIN link (seen in other demos),
 or an unlinked CH+/VIN with externally powered Nano is recommended
 to safely power the microcontroller where a connected device might exceed the power limits.
CODE
CODE
/*
FourBoardBasicSetup.ino - Basic FourBoard1.1 Setup Code
for use on Arduino Nano with Mega328p

created 9/29/2017
This demo code is in the public domain.
http://www.hillway.us/fourboard
*/

const int DIAL1PIN = A0;
const int DIAL2PIN = A1;
const int DIAL3PIN = A2;
const int DIAL4PIN = A3;

const int BUTTON1PIN = 2;
const int BUTTON2PIN = 5;
const int BUTTON3PIN = 7;
const int BUTTON4PIN = 8;

const int MOSFET1PIN = 6;
const int MOSFET2PIN = 9;
const int MOSFET3PIN = 10;
const int MOSFET4PIN = 11;



const unsigned long showStatusEvery = 1000;
unsigned long lastShowStatus = 0;

void setup()
{
    pinMode(DIAL1PIN, INPUT);
    pinMode(DIAL2PIN, INPUT);
    pinMode(DIAL3PIN, INPUT);
    pinMode(DIAL4PIN, INPUT);
    pinMode(BUTTON1PIN, INPUT);
    pinMode(BUTTON2PIN, INPUT);
    pinMode(BUTTON3PIN, INPUT);
    pinMode(BUTTON4PIN, INPUT);
    pinMode(MOSFET1PIN, OUTPUT);
    pinMode(MOSFET2PIN, OUTPUT);
    pinMode(MOSFET3PIN, OUTPUT);
    pinMode(MOSFET4PIN, OUTPUT);

    pinMode(13, OUTPUT);
    Serial.begin(9600);
    attachInterrupt(0, showNow, RISING); // interrupt for button1
}

void loop()
{
    // Dials to PWM Power Output
    analogWrite(MOSFET1PIN, map(analogRead(DIAL1PIN), 0, 1023, 0, 255));
    analogWrite(MOSFET2PIN, map(analogRead(DIAL2PIN), 0, 1023, 0, 255));
    analogWrite(MOSFET3PIN, map(analogRead(DIAL3PIN), 0, 1023, 0, 255));
    analogWrite(MOSFET4PIN, map(analogRead(DIAL4PIN), 0, 1023, 0, 255));

    // Light Pin13 LED on any Button Press
    if(digitalRead(BUTTON1PIN) || digitalRead(BUTTON2PIN) || digitalRead(BUTTON3PIN) || digitalRead(BUTTON4PIN))
    {
        digitalWrite(13, HIGH);
    }
    else
    {
        digitalWrite(13, LOW);
    }

    if(millis() - lastShowStatus >= showStatusEvery)
    {
        lastShowStatus = millis();
        showStatus();
    }
}

void showStatus()
{
    Serial.write("DIAL1:");
    Serial.println(analogRead(DIAL1PIN));
    Serial.write("DIAL2:");
    Serial.println(analogRead(DIAL2PIN));
    Serial.write("DIAL3:");
    Serial.println(analogRead(DIAL3PIN));
    Serial.write("DIAL4:");
    Serial.println(analogRead(DIAL4PIN));

    Serial.write("BUTTON1:");
    Serial.println(digitalRead(BUTTON1PIN));
    Serial.write("BUTTON2:");
    Serial.println(digitalRead(BUTTON2PIN));
    Serial.write("BUTTON3:");
    Serial.println(digitalRead(BUTTON3PIN));
    Serial.write("BUTTON4:");
    Serial.println(digitalRead(BUTTON4PIN));
}

void showNow()
{
    lastShowStatus = 0;
}