Configure your CONTROL-BOX

Control box with an Arduino Microcontroller

Item #CONTROL-BOX

$
 available

Overview

Project: CS_Basic Control Box

This control box is designed to fulfill the need for STEM system concept testing in the prototype phase of the project. This Control Box provides basic control like turn on/off the system, variable speed control, variable direction control. For instance, the switched could be used to turn on/off light or fan, etc. where the knob could be used to control motor speed, LED brightness or even a sound system. 

1. Parts list:

  • 1 * Arduino Uno R3: Item #ARDUINO UNO R3
  • 2 * Micro Switch: Item #S18-23A-H
  • 2* 10K Ohm resistor: Item #RG10K
  • 1 * Potentiometer: Item #31VA302
  • 1 * Knob
  • Project Box: Item #PB-3P

 

2.Wiring

  • CS_Basic Control Box Schematic

 

3.Build

              A. Switches and knob

             

 

               

 

    B.Connect to Arduino 

  

 C. Assemble

   Drill holes where you want to install the switches and the knob. (LED lights are optional)

 

      5. Code

/*
-----------------Note----------------------
Date: 11-27-2019
Project Name: CS_BasicControlBox (BCB)
Author: Khang Nguyen
*/


const int R_button = 6;
const int L_button = 7;

const int LED2 = 3 ;
const int LED1 = 5 ;

const int Knob = A0 ;

const int test_P1 = 8;
const int test_P2 = 9;
const int test_P3 = 10;

int R_button_State = 0;
int L_button_State = 0;

int forward = 0 ;
int backward = 0;

int Knob_Value = 0 ;
long P_Knob_Value = 0 ;

void setup()

{
Serial.begin(9600);
pinMode(R_button, INPUT);
pinMode(L_button, INPUT);

pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}

void loop()

{

//====================Checking_Input====================//
R_button_State = digitalRead(R_button);
L_button_State = digitalRead(L_button);
Knob_Value = analogRead(Knob);
P_Knob_Value = map(Knob_Value,1023,0,9,255);

Serial.print("Knob Value: ");Serial.println(P_Knob_Value);

if ( P_Knob_Value > 10)
{
//====================Right_Button====================//
if (R_button_State == LOW)
{
analogWrite(LED1,P_Knob_Value );
Serial.println("Right button press!");
}

if (R_button_State == HIGH)
{
analogWrite(LED1,0);
Serial.println("Right button release!");
}
//====================Left_Button====================//
if (L_button_State == LOW)
{
analogWrite(LED2,P_Knob_Value );
Serial.println("Left button press!");
}

if (L_button_State == HIGH)
{
analogWrite(LED2,0);
Serial.println("Left button release!");

}
//====================Both_Button====================//
if (L_button_State == LOW && R_button_State == LOW )
{
analogWrite(LED1,0);
analogWrite(LED2,200);
delay(Knob_Value);
analogWrite(LED1,200);
analogWrite(LED2,0);
delay(Knob_Value);
}
}
}

 

Conclusion

As the project grows, the Control Box can also be upgraded to an Advance Control Box, with switches, LCD display, and joystick control depend on the need of the project.