Commit a6626432 authored by Árni Björnsson's avatar Árni Björnsson
Browse files

Updated final project page

parent d1f01afc
Pipeline #317294 passed with stage
in 49 seconds
......@@ -381,18 +381,72 @@ Quick overview of the electronic boards I made:
Handles the logic and syncs the LED statuses between button boards.
<figure markdown>
![Control board](../images/final/cb.jpg)
<figcaption>Control board</figcaption>
</figure>
| Components | Qty |
| --- | --- |
| 4.99k res | 2 |
| 1uf cap | 1 |
| ATtiny 1614 | 1 |
| 1x3 pin header | 1 |
| 1x4 pin header | 1 |
| 1x6 pin header | 1 |
| 1x7 pin header | 1 |
### Button board
Takes input from user and turn LEDs on and off according the commands from the control board.
<figure markdown>
![Button board](../images/final/bb.jpg)
<figcaption>Button board</figcaption>
</figure>
| Components | Qty |
| --- | --- |
| SMD LED | 3 |
| 1k res | 3 |
| 4.99k res | 2 |
| 1uf cap | 1 |
| BUTTON_B3SN | 3 |
| ATtiny 1614 | 1 |
| 1x3 pin header | 1 |
| 1x4 pin header | 1 |
| 1x6 pin header | 1 |
### Power supply board
A simple USB connector with a 5V 1A regulator that supplies the boards. Should handle plenty of additional items.
<figure markdown>
![Jack board](../images/final/psu.jpg)
<figcaption>Jack board</figcaption>
</figure>
| Components | Qty |
| --- | --- |
| USB_B_Mini | 1 |
| Regulator_Linear_NCP1117-5.0V-1A | 1 |
| 1uF | 1 |
| 1x3 pin header | 2 |
### Jack board
Mini jack connector is used to handle communications between the two units.
<figure markdown>
![Jack board](../images/final/jack01.jpg)
<figcaption>Jack board</figcaption>
</figure>
| Components | Qty |
| --- | --- |
| SJ1-2533-SMT | 1 |
| 1x2 pin header | 1 |
## KiCad files
Below are the KiCad projects I created for the boards.
......@@ -403,3 +457,156 @@ Below are the KiCad projects I created for the boards.
| [Button board](../files/final/button-board.rar) |
| [Power supply board](../files/final/psu.rar) |
| [Jack board](../files/final/JackBoard.rar) |
## Control board code
The code for the control board:
```
//#include <Arduino.h>
#include <Wire.h>
byte ledArray[3] = {0,0,0};
void recieveEvent(int howMany){
for (int i = 0; i < howMany; i++)
{
ledArray[i] = Wire.read();
}
}
void sendLedArrayToBothBoards(){
Wire.beginTransmission(1);
for (int i = 0; i < 3; i++)
{
Wire.write(ledArray[i]);
}
Wire.endTransmission();
Wire.beginTransmission(2);
for (int i = 0; i < 3; i++)
{
Wire.write(ledArray[i]);
}
Wire.endTransmission();
}
void setup() {
Wire.begin();
Wire.onReceive(recieveEvent); // function that executes whenever data is received from writer
sendLedArrayToBothBoards();
delay(1000);
}
void loop() {
sendLedArrayToBothBoards();
delay(100);
Wire.requestFrom(1, 3);
for (int i = 0; i < 3; i++)
{
ledArray[i] = Wire.read();
}
sendLedArrayToBothBoards();
delay(100);
Wire.requestFrom(2, 3);
for (int i = 0; i < 3; i++)
{
ledArray[i] = Wire.read();
}
}
```
## Button board code
```
#include <Arduino.h>
#include <Wire.h>
// Define buttons 1,2,3 as BUTTON_1, BUTTON_2, BUTTON_3 with PIN_PA1, PIN_PA2, PIN_PA3 respectively
#define BUTTON_1 PIN_PA1
#define BUTTON_2 PIN_PA2
#define BUTTON_3 PIN_PA3
// https://www.e-tinkers.com/2021/05/the-simplest-button-debounce-solution/
bool debounce_btn1() {
static uint16_t state = 0;
state = (state<<1) | digitalRead(BUTTON_1) | 0xe000;
return (state == 0xff00);
}
bool debounce_btn2() {
static uint16_t state = 0;
state = (state<<1) | digitalRead(BUTTON_2) | 0xe000;
return (state == 0xff00);
}
bool debounce_btn3() {
static uint16_t state = 0;
state = (state<<1) | digitalRead(BUTTON_3) | 0xe000;
return (state == 0xff00);
}
// Define leds 1,2,3 as LED_1, LED_2, LED_3 with PIN_PA4, PIN_PA5, PIN_PA6 respectively
#define LED_1 PIN_PA4
#define LED_2 PIN_PA5
#define LED_3 PIN_PA6
byte ledArray[3] = {0,0,0};
void receiveEvent(int howMany){
for (int i = 0; i < howMany; i++)
{
ledArray[i] = Wire.read();
}
}
void writeEvent()
{
Wire.write(ledArray, 3);
}
void setup() {
Wire.begin(1); // join i2c bus with address #1(parental button board) or #2(child button board)
Wire.onReceive(receiveEvent); // function that executes whenever data is received from writer
Wire.onRequest(writeEvent); // function that executes whenever data is requested from reader
// Set button pins as input_pullup
pinMode(BUTTON_1, INPUT_PULLUP);
pinMode(BUTTON_2, INPUT_PULLUP);
pinMode(BUTTON_3, INPUT_PULLUP);
// Set led pins
pinMode(LED_1, OUTPUT);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT);
// Set leds off
digitalWrite(LED_1, LOW);
digitalWrite(LED_2, LOW);
digitalWrite(LED_3, LOW);
}
void loop() {
digitalWrite(LED_1, ledArray[0]);
digitalWrite(LED_2, ledArray[1]);
digitalWrite(LED_3, ledArray[2]);
if(debounce_btn1()) {
ledArray[0] = !ledArray[0];
}
if(debounce_btn2()) {
ledArray[1] = !ledArray[1];
}
if(debounce_btn3()) {
ledArray[2] = !ledArray[2];
}
delay(10);
}
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment