Template
This is a starting template for the Locus Incepti Board.
Explanation
All the pins are named for the components used on the Locus Incepti Board.
// Push Buttons
const int rPB = 7; // Red push button connected to pin 7
const int yPB = 9; // Yellow push button connected to pin 9
const int gPB = 11; // Green push button connected to pin 11
const int bPB = 13; // Blue push button connected to pin 13
const int oPB = 24; // Onboard push button connected to pin 24
// LEDs
const int rLED = 6; // Red LED connected to pin 6
const int yLED = 8; // Yellow LED connected to pin 8
const int gLED = 10; // Green LED connected to pin 10
const int bLED = 12; // Blue LED connected to pin 12
const int oLED = 25; // Blue LED connected to pin 25
const int NeoPix = 23; // NeoPixel line connected to pin 23
// IR devices
const int IRrx = yPB; // IR receive device connected to pin 9
const int IRtx = yLED; // IR transmit device connected to pin 8
// Rotary Encoder
const int encA = 2; // Encoder A connected to pin 2
const int encB = 3; // Encoder B connected to pin 3
// Joystick
const int xJS = A0; // Joystick X axis potentiometer to pin A0
const int yJS = A1; // Joystick Y axis potentiometer to pin A1
// Buzzer
const int bzr = 22; // Buzzer connected to pin 22
// Pot & Battery Voltage
const int batV = A3; // Photo resistor connected to pin A3
const int pot = A2; // Pot connected to pin A2
// NOTE: A3 is not available on the original Pico controller
// Serial Port
const int Tx = 0; // Serial Transmit (GPIO 0)
const int Rx = 1; // Serial Receive (GPIO 1)
The pinMode() statements are also included. This pinSet() function is called from the Setup() function.
void pinSet()
{
pinMode(rLED, OUTPUT);
pinMode(yLED, OUTPUT);
pinMode(gLED, OUTPUT);
pinMode(bLED, OUTPUT);
pinMode(oLED, OUTPUT);
//pinMode(IRtx, OUTPUT);
pinMode(bzr, OUTPUT);
pinMode(rPB, INPUT_PULLUP);
pinMode(yPB, INPUT_PULLUP);
pinMode(gPB, INPUT_PULLUP);
pinMode(bPB, INPUT_PULLUP);
pinMode(oPB, INPUT_PULLUP);
//pinMode(IRrx, INPUT);
pinMode(encA, INPUT_PULLUP);
pinMode(encB, INPUT_PULLUP);
}
Finally, the count variable and the Encode() function are setup to use the rotary encoder.
volatile int count; // count holds the encoder variable.
void Encode() // Interrupt routine to manage the encoders
{ // this routine is called if encB transitions from HIGH to LOW
if (digitalRead(encB)) // Based on the state of encA we know the direction
count++;
else
count--;
}
The PicoPins3.h file is added to the project by saving it in the project directory and calling it using the include statement.
#include"PicoPins3.h"
The pinSet() function is included in the setup function as well as the Serial.begin() and Encoder Interrupt statement. Removing the comment (//) slashes will activate these statements.
void setup() {
pinSet();
//Serial.begin(115200);
//attachInterrupt(digitalPinToInterrupt(2), Encode, FALLING);
}
Code
Libraries
No Libraries used.