]> kolegite.com Git - vmks.git/commitdiff
Added DC motor and servo example and moved examples to a separate folder
authorvl_garistov <vl_garistov@gmail.com>
Tue, 17 Nov 2020 22:28:25 +0000 (00:28 +0200)
committervl_garistov <vl_garistov@gmail.com>
Tue, 17 Nov 2020 22:28:25 +0000 (00:28 +0200)
35 files changed:
Datasheets/l293.pdf [new file with mode: 0644]
Examples/3x3-LED_BTN-Matrix-Transpose/3x3-LED_BTN-Matrix-Transpose-Schematic.png [new file with mode: 0644]
Examples/3x3-LED_BTN-Matrix-Transpose/3x3-LED_BTN-Matrix-Transpose.ino [new file with mode: 0644]
Examples/Analog_Serial_Send_-_LDR/Analog_Serial_Send_-_LDR-Schematic.png [new file with mode: 0644]
Examples/Analog_Serial_Send_-_LDR/Analog_Serial_Send_-_LDR.ino [new file with mode: 0644]
Examples/Blink_LED_Low_Level/Blink_LED_Low_Level.ino [new file with mode: 0644]
Examples/Car_dodge/Car_dodge.ino [new file with mode: 0644]
Examples/Car_dodge/Car_dodge.png [new file with mode: 0644]
Examples/DC_motor_and_servo/DC_motor_and_servo.ino [new file with mode: 0644]
Examples/DC_motor_and_servo/DC_motor_and_servo.png [new file with mode: 0644]
Examples/Digital_Blink_with_Button/Digital_Blink_with_Button-Schematic.png [new file with mode: 0644]
Examples/Digital_Blink_with_Button/Digital_Blink_with_Button.ino [new file with mode: 0644]
Examples/LED_Strip_Moving_LED_-_Interrupt/LED Strip Moving LED - Interrupt Tinkercad.png [new file with mode: 0644]
Examples/LED_Strip_Moving_LED_-_Interrupt/LED_Strip_Moving_LED_-_Interrupt.ino [new file with mode: 0644]
Examples/LED_Strip_Moving_LED_-_Polling/LED Strip Moving LED - Polling Tinkercad.png [new file with mode: 0644]
Examples/LED_Strip_Moving_LED_-_Polling/LED_Strip_Moving_LED_-_Polling.ino [new file with mode: 0644]
Examples/Pinouts/ATmega328-Pinout-1.jpeg [new file with mode: 0644]
Examples/Pinouts/ATmega328-Pinout-2.png [new file with mode: 0644]
Examples/Pinouts/Arduino-Uno-Pin-Diagram-2.png [new file with mode: 0644]
Examples/Pinouts/Arduino-Uno-Pin-Diagram-3.png [new file with mode: 0644]
Examples/Pinouts/Arduino-Uno-Pin-Diagram-4.png [new file with mode: 0644]
Examples/Pinouts/Arduino-Uno-Pin-Diagram.png [new file with mode: 0644]
Examples/Pinouts/Arduino-Uno-Pinout-Digital-Pins.jpg [new file with mode: 0644]
Examples/TUES-LED_strip_1/TUES-LED_strip_1.ino [new file with mode: 0644]
Examples/TUES-LED_strip_1/TUES-LED_strip_1.png [new file with mode: 0644]
Examples/TUES-LED_strip_1/WS2812B.pdf [new file with mode: 0644]
Examples/TUES-LED_strip_1/mona_lisa.ppm [new file with mode: 0644]
Examples/TUES-LED_strip_1/nozdra.ppm [new file with mode: 0644]
Examples/TUES-LED_strip_1/rick_astley.jpg [new file with mode: 0644]
Examples/TUES-LED_strip_1/sako.ppm.txt [new file with mode: 0644]
Examples/Timer_1_10kHz_ISR/Timer_1_10kHz_ISR.ino [new file with mode: 0644]
Examples/Timer_ISR/Timer_ISR.ino [new file with mode: 0644]
Examples/UART-Send/UART-Send.ino [new file with mode: 0644]
Examples/external_interrupt/external_interrupt.ino [new file with mode: 0644]
Examples/external_interrupt/external_interrupt.png [new file with mode: 0644]

diff --git a/Datasheets/l293.pdf b/Datasheets/l293.pdf
new file mode 100644 (file)
index 0000000..1a535cf
Binary files /dev/null and b/Datasheets/l293.pdf differ
diff --git a/Examples/3x3-LED_BTN-Matrix-Transpose/3x3-LED_BTN-Matrix-Transpose-Schematic.png b/Examples/3x3-LED_BTN-Matrix-Transpose/3x3-LED_BTN-Matrix-Transpose-Schematic.png
new file mode 100644 (file)
index 0000000..472ae2b
Binary files /dev/null and b/Examples/3x3-LED_BTN-Matrix-Transpose/3x3-LED_BTN-Matrix-Transpose-Schematic.png differ
diff --git a/Examples/3x3-LED_BTN-Matrix-Transpose/3x3-LED_BTN-Matrix-Transpose.ino b/Examples/3x3-LED_BTN-Matrix-Transpose/3x3-LED_BTN-Matrix-Transpose.ino
new file mode 100644 (file)
index 0000000..e265976
--- /dev/null
@@ -0,0 +1,85 @@
+#define LED_ROW1 11  // Active HIGH | Inactive LOW
+#define LED_ROW2 10 // Active HIGH | Inactive LOW
+#define LED_ROW3 9  // Active HIGH | Inactive LOW
+#define LED_COL1 8  // Active LOW  | Inactive HIGH
+#define LED_COL2 7  // Active LOW  | Inactive HIGH
+#define LED_COL3 6  // Active LOW  | Inactive HIGH
+
+#define BTN_ROW1 A3 // Active OUTPUT-LOW | Inactive INPUT - PULLUP
+#define BTN_ROW2 A4 // Active OUTPUT-LOW | Inactive INPUT - PULLUP
+#define BTN_ROW3 A5 // Active OUTPUT-LOW | Inactive INPUT - PULLUP
+#define BTN_COL1 A0 // Active OUTPUT-LOW | Inactive INPUT - PULLUP
+#define BTN_COL2 A1 // Active OUTPUT-LOW | Inactive INPUT - PULLUP
+#define BTN_COL3 A2 // Active OUTPUT-LOW | Inactive INPUT - PULLUP
+
+const uint8_t led_col[3] = {LED_COL1, LED_COL2, LED_COL3};
+const uint8_t led_row[3] = {LED_ROW1, LED_ROW2, LED_ROW3};
+
+const uint8_t btn_col[3] = {BTN_COL1, BTN_COL2, BTN_COL3};
+const uint8_t btn_row[3] = {BTN_ROW1, BTN_ROW2, BTN_ROW3};
+
+uint8_t state_1[3][3] =
+{
+  {0, 0, 0},
+  {0, 0, 0},
+  {0, 0, 0}
+};
+
+void setup()
+{
+  int i = 0;
+
+  for (i = 0; i < 3; i++)
+  {
+    pinMode(led_row[i], OUTPUT);
+    digitalWrite(led_row[i], LOW);
+    pinMode(led_col[i], OUTPUT);
+    digitalWrite(led_col[i], HIGH);
+
+    pinMode(btn_row[i], INPUT_PULLUP);
+    pinMode(btn_col[i], INPUT_PULLUP);
+  }
+}
+
+void loop()
+{
+  // Button scan
+  for (byte col = 0; col < 3; col++)
+  {
+    pinMode(btn_col[col], OUTPUT);
+    digitalWrite(btn_col[col], LOW);
+    for (byte row = 0; row < 3; row++)
+    {
+      state_1[row][col] = !digitalRead(btn_row[row]);
+    }
+    pinMode(btn_col[col], INPUT_PULLUP);
+  }
+
+  // Transpose
+  for (int i = 0; i < 3; i++)
+  {
+    for (int j = i + 1; j < 3; j++)
+    {
+      int temp;
+      temp = state_1[i][j];
+      state_1[i][j] = state_1[j][i];
+      state_1[j][i] = temp;
+    }
+  }
+
+  // LED update
+  for (byte col = 0; col < 3; col++)
+  {
+    for (byte row = 0; row < 3; row++)
+    {
+      digitalWrite(led_row[row], state_1[row][col]);
+    }
+    digitalWrite(led_col[col], LOW);
+    delay(5);
+    digitalWrite(led_col[col], HIGH);
+    for (byte row = 0; row < 3; row++)
+    {
+      digitalWrite(led_row[row], LOW);
+    }
+  }
+}
diff --git a/Examples/Analog_Serial_Send_-_LDR/Analog_Serial_Send_-_LDR-Schematic.png b/Examples/Analog_Serial_Send_-_LDR/Analog_Serial_Send_-_LDR-Schematic.png
new file mode 100644 (file)
index 0000000..49d7cc0
Binary files /dev/null and b/Examples/Analog_Serial_Send_-_LDR/Analog_Serial_Send_-_LDR-Schematic.png differ
diff --git a/Examples/Analog_Serial_Send_-_LDR/Analog_Serial_Send_-_LDR.ino b/Examples/Analog_Serial_Send_-_LDR/Analog_Serial_Send_-_LDR.ino
new file mode 100644 (file)
index 0000000..6cb7a7b
--- /dev/null
@@ -0,0 +1,16 @@
+#define LDR A0
+
+uint16_t value = 0;
+
+void setup()
+{
+  pinMode(A0, INPUT);
+  Serial.begin(9600);
+}
+
+void loop()
+{
+  value = analogRead(LDR);
+  Serial.println(value);
+  delay(100);
+}
diff --git a/Examples/Blink_LED_Low_Level/Blink_LED_Low_Level.ino b/Examples/Blink_LED_Low_Level/Blink_LED_Low_Level.ino
new file mode 100644 (file)
index 0000000..96ba026
--- /dev/null
@@ -0,0 +1,12 @@
+void setup() {
+  // put your setup code here, to run once:
+  DDRB |= (1 << PB5);
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  PORTB |= (1 << PB5);
+  _delay_ms(500);
+  PORTB &= ~(1 << PB5);
+  _delay_ms(500);
+}
diff --git a/Examples/Car_dodge/Car_dodge.ino b/Examples/Car_dodge/Car_dodge.ino
new file mode 100644 (file)
index 0000000..6925a5e
--- /dev/null
@@ -0,0 +1,189 @@
+#include <Adafruit_NeoPixel.h>
+
+#define NUM_PIXELS 6
+#define MIN_DELAY 30
+
+#define TOP_ROW 2
+#define MID_ROW 3
+#define BOT_ROW 4
+#define UP_BUTTON 6
+#define DOWN_BUTTON 5
+#define NOISE A0
+
+#define PLAYER 1
+#define CAR 2
+#define EMPTY 0
+#define CRASH 3
+
+Adafruit_NeoPixel top_row(NUM_PIXELS, TOP_ROW, NEO_GRB);
+Adafruit_NeoPixel mid_row(NUM_PIXELS, MID_ROW, NEO_GRB);
+Adafruit_NeoPixel bot_row(NUM_PIXELS, BOT_ROW, NEO_GRB);
+
+// Video RAM - every element corresponds to one pixel
+int vram[3][NUM_PIXELS] = {{0}};  // 2 - TOP, 1 - MID, 0 - BOT
+int player_pos = 1;
+int next_car_in = 1;
+int delay_time = 500;
+int crashed = 0;
+
+void setup()
+{
+  pinMode(TOP_ROW, OUTPUT);
+    pinMode(MID_ROW, OUTPUT);
+    pinMode(BOT_ROW, OUTPUT);
+    pinMode(UP_BUTTON, INPUT);
+    pinMode(DOWN_BUTTON, INPUT);
+    pinMode(NOISE, INPUT);
+    
+    // LED strip initialization
+    top_row.begin();
+    mid_row.begin();
+    bot_row.begin();
+  
+    // set the seed for the random number generator
+    int seed = analogRead(NOISE) * 42;
+    randomSeed(seed);
+  
+    Serial.begin(9600);
+}
+
+void loop()
+{
+    int i;
+    int new_car;
+    
+    // update player position
+  if (digitalRead(UP_BUTTON) == HIGH)
+    {
+        player_pos++;
+    }
+    else if (digitalRead(DOWN_BUTTON) == HIGH)
+    {
+        player_pos--;
+    }
+    if (player_pos > 2)
+    {
+      player_pos = 2;
+    }
+    else if (player_pos < 0)
+    {
+      player_pos = 0;
+    }
+    
+    // draw the player
+    for (i = 0; i < 3; i++)
+    {
+        if (player_pos == i)
+        {
+            // detect collision
+            if (vram[i][1] == CAR)
+            {
+              vram[i][0] = CRASH;
+                crashed = 1;
+            }
+            else
+            {
+              vram[i][0] = PLAYER;
+            }
+        }
+        else
+        {
+            vram[i][0] = vram[i][1];
+        }
+    }
+  
+    // move everything one pixel to the left
+    for (i = 1; i < (NUM_PIXELS - 1); i++)
+    {
+        vram[0][i] = vram[0][i + 1];
+        vram[1][i] = vram[1][i + 1];
+        vram[2][i] = vram[2][i + 1];
+    }
+    
+    // generate next car
+    for (i = 0; i < 3; i++)
+    {
+        vram[i][NUM_PIXELS - 1] = EMPTY;
+    }
+    next_car_in--;
+    if (next_car_in == 0)
+    {
+        new_car = random(3);
+        vram[new_car][NUM_PIXELS - 1] = CAR;
+        next_car_in = 3;
+    }
+    
+    // render the image
+    for (i = 0; i < NUM_PIXELS; i++)
+    {
+        if (vram[0][i] == EMPTY)
+        {
+          bot_row.setPixelColor(i, bot_row.Color(0, 0, 0));
+        }
+        else if (vram[0][i] == CAR)
+        {
+          bot_row.setPixelColor(i, bot_row.Color(0, 0, 255));
+        }
+        else if (vram[0][i] == PLAYER)
+        {
+          bot_row.setPixelColor(i, bot_row.Color(0, 255, 0));
+        }
+        else if (vram[0][i] == CRASH)
+        {
+          bot_row.setPixelColor(i, bot_row.Color(255, 0, 0));
+        }
+      
+        if (vram[1][i] == EMPTY)
+        {
+          mid_row.setPixelColor(i, mid_row.Color(0, 0, 0));
+        }
+        else if (vram[1][i] == CAR)
+        {
+          mid_row.setPixelColor(i, mid_row.Color(0, 0, 255));
+        }
+        else if (vram[1][i] == PLAYER)
+        {
+          mid_row.setPixelColor(i, mid_row.Color(0, 255, 0));
+        }
+        else if (vram[1][i] == CRASH)
+        {
+          mid_row.setPixelColor(i, mid_row.Color(255, 0, 0));
+        }
+      
+        if (vram[2][i] == EMPTY)
+        {
+          top_row.setPixelColor(i, top_row.Color(0, 0, 0));
+        }
+        else if (vram[2][i] == CAR)
+        {
+          top_row.setPixelColor(i, top_row.Color(0, 0, 255));
+        }
+        else if (vram[2][i] == PLAYER)
+        {
+          top_row.setPixelColor(i, top_row.Color(0, 255, 0));
+        }
+        else if (vram[2][i] == CRASH)
+        {
+          top_row.setPixelColor(i, top_row.Color(255, 0, 0));
+        }
+    }
+    top_row.show();
+    mid_row.show();
+    bot_row.show();
+    Serial.println(delay_time);
+    // stop the game if crashed
+    if (crashed)
+    {
+        while (1);
+    }
+    // delay before the next frame
+    else
+    {
+        delay(delay_time);
+    }
+    // slowly make the game faster
+    if (delay_time > MIN_DELAY)
+    {
+        delay_time--;
+    }
+} 
diff --git a/Examples/Car_dodge/Car_dodge.png b/Examples/Car_dodge/Car_dodge.png
new file mode 100644 (file)
index 0000000..dbbbc07
Binary files /dev/null and b/Examples/Car_dodge/Car_dodge.png differ
diff --git a/Examples/DC_motor_and_servo/DC_motor_and_servo.ino b/Examples/DC_motor_and_servo/DC_motor_and_servo.ino
new file mode 100644 (file)
index 0000000..70011fc
--- /dev/null
@@ -0,0 +1,87 @@
+#include <Servo.h>
+
+#define A1    6
+#define A2    5
+#define EN_L  7
+#define A3    9
+#define A4    11
+#define EN_R  4
+#define SERVO_PIN 10
+
+Servo aservo;
+
+void forward(uint8_t speed);
+void reverse(uint8_t speed);
+void turn_left(uint8_t speed);
+void turn_right(uint8_t speed);
+
+void setup()
+{
+    pinMode(A1, OUTPUT);
+    pinMode(A2, OUTPUT);
+    pinMode(EN_L, OUTPUT);
+    digitalWrite(A1, LOW);
+    digitalWrite(A2, LOW);
+    digitalWrite(EN_L, HIGH);
+    pinMode(A3, OUTPUT);
+    pinMode(A4, OUTPUT);
+    pinMode(EN_R, OUTPUT);
+    digitalWrite(A3, LOW);
+    digitalWrite(A4, LOW);
+    digitalWrite(EN_R, HIGH);
+  
+    aservo.attach(SERVO_PIN);
+}
+
+void loop()
+{
+    /*
+  digitalWrite(A1, HIGH);
+    analogWrite(A2, 128);
+    digitalWrite(EN_L, HIGH);
+  
+    aservo.write(90);
+    */
+  
+    for (uint8_t i = 0; i < 4; i++)
+    {
+        forward(255);
+        delay(5000);
+        turn_right(128);
+        delay(1000);
+    }
+    digitalWrite(EN_L, LOW);
+    digitalWrite(EN_R, LOW);
+}
+
+void forward(uint8_t speed)
+{
+    analogWrite(A1, speed);
+    digitalWrite(A2, LOW);
+    analogWrite(A3, speed);
+    digitalWrite(A4, LOW);  
+}
+
+void reverse(uint8_t speed)
+{
+    analogWrite(A2, speed);
+    digitalWrite(A1, LOW);
+    analogWrite(A4, speed);
+    digitalWrite(A3, LOW);  
+}
+
+void turn_left(uint8_t speed)
+{
+    analogWrite(A2, speed);
+    digitalWrite(A1, LOW);
+    analogWrite(A3, speed);
+    digialWrite(A4, LOW);  
+}
+
+void turn_right(uint8_t speed)
+{
+    analogWrite(A1, speed);
+    digitalWrite(A2, LOW);
+    analogWrite(A4, speed);
+    digitalWrite(A3, LOW);  
+}
diff --git a/Examples/DC_motor_and_servo/DC_motor_and_servo.png b/Examples/DC_motor_and_servo/DC_motor_and_servo.png
new file mode 100644 (file)
index 0000000..d3e4059
Binary files /dev/null and b/Examples/DC_motor_and_servo/DC_motor_and_servo.png differ
diff --git a/Examples/Digital_Blink_with_Button/Digital_Blink_with_Button-Schematic.png b/Examples/Digital_Blink_with_Button/Digital_Blink_with_Button-Schematic.png
new file mode 100644 (file)
index 0000000..e15310c
Binary files /dev/null and b/Examples/Digital_Blink_with_Button/Digital_Blink_with_Button-Schematic.png differ
diff --git a/Examples/Digital_Blink_with_Button/Digital_Blink_with_Button.ino b/Examples/Digital_Blink_with_Button/Digital_Blink_with_Button.ino
new file mode 100644 (file)
index 0000000..e5ef2d4
--- /dev/null
@@ -0,0 +1,32 @@
+#define BTN 2
+#define LED 5
+
+byte stateON = false;
+uint8_t count = 0;
+
+void setup()
+{
+  pinMode(BTN, INPUT);
+  pinMode(LED, OUTPUT);
+}
+
+void loop()
+{
+  if(digitalRead(BTN) == 0)
+  {
+    stateON = true;
+  }
+  
+  if(stateON == true)
+  {
+    digitalWrite(LED, HIGH);
+    delay(500);
+    digitalWrite(LED, LOW);
+    delay(500);
+    count++;
+    if(count >= 5)
+    {
+      stateON = false;
+    }
+  }
+}
diff --git a/Examples/LED_Strip_Moving_LED_-_Interrupt/LED Strip Moving LED - Interrupt Tinkercad.png b/Examples/LED_Strip_Moving_LED_-_Interrupt/LED Strip Moving LED - Interrupt Tinkercad.png
new file mode 100644 (file)
index 0000000..1284fcc
Binary files /dev/null and b/Examples/LED_Strip_Moving_LED_-_Interrupt/LED Strip Moving LED - Interrupt Tinkercad.png differ
diff --git a/Examples/LED_Strip_Moving_LED_-_Interrupt/LED_Strip_Moving_LED_-_Interrupt.ino b/Examples/LED_Strip_Moving_LED_-_Interrupt/LED_Strip_Moving_LED_-_Interrupt.ino
new file mode 100644 (file)
index 0000000..5fdcdb9
--- /dev/null
@@ -0,0 +1,45 @@
+#include <Adafruit_NeoPixel.h>
+#define NUM_PIXELS 10
+#define PIN 5
+Adafruit_NeoPixel strip(NUM_PIXELS, PIN, NEO_GRB);
+
+#define BTN_LEFT 3
+#define BTN_RIGHT 2
+
+volatile uint8_t position = 0;
+
+void L_button_pressed_ISR();
+void R_button_pressed_ISR();
+
+void setup() {
+  pinMode(BTN_LEFT, INPUT_PULLUP);
+  pinMode(BTN_RIGHT, INPUT_PULLUP);
+  attachInterrupt(digitalPinToInterrupt(BTN_LEFT), L_button_pressed_ISR, FALLING);
+  attachInterrupt(digitalPinToInterrupt(BTN_RIGHT), R_button_pressed_ISR, RISING);
+
+  pinMode(PIN, OUTPUT);
+  strip.begin();
+}
+
+void L_button_pressed_ISR() {
+  if (position > 0) position--;
+}
+
+void R_button_pressed_ISR() {
+  if (position < (NUM_PIXELS - 1)) position++;
+}
+
+void loop() {
+  for (int i = 0 ; i < NUM_PIXELS; i++)
+  {
+    if (i == position)
+    {
+      strip.setPixelColor(i, strip.Color(255, 0, 0));
+    }
+    else
+    {
+      strip.setPixelColor(i, strip.Color(0, 0, 255));
+    }
+  }
+  strip.show();
+}
diff --git a/Examples/LED_Strip_Moving_LED_-_Polling/LED Strip Moving LED - Polling Tinkercad.png b/Examples/LED_Strip_Moving_LED_-_Polling/LED Strip Moving LED - Polling Tinkercad.png
new file mode 100644 (file)
index 0000000..70f3c24
Binary files /dev/null and b/Examples/LED_Strip_Moving_LED_-_Polling/LED Strip Moving LED - Polling Tinkercad.png differ
diff --git a/Examples/LED_Strip_Moving_LED_-_Polling/LED_Strip_Moving_LED_-_Polling.ino b/Examples/LED_Strip_Moving_LED_-_Polling/LED_Strip_Moving_LED_-_Polling.ino
new file mode 100644 (file)
index 0000000..6b452fd
--- /dev/null
@@ -0,0 +1,42 @@
+#include <Adafruit_NeoPixel.h>
+#define NUM_PIXELS 10
+#define PIN 5
+Adafruit_NeoPixel strip(NUM_PIXELS, PIN, NEO_GRB);
+
+#define BTN_LEFT 3
+#define BTN_RIGHT 2
+
+uint8_t position = 0;
+
+void setup() {
+  pinMode(BTN_LEFT, INPUT_PULLUP);
+  pinMode(BTN_RIGHT, INPUT_PULLUP);
+
+  pinMode(PIN, OUTPUT);
+  strip.begin();
+}
+
+void loop() {
+  if (digitalRead(BTN_LEFT) == LOW)
+  {
+    if (position > 0) position--;
+  }
+  if (digitalRead(BTN_RIGHT) == LOW)
+  {
+    if (position < (NUM_PIXELS - 1)) position++;
+  }
+  delay(50);
+
+  for (int i = 0 ; i < NUM_PIXELS; i++)
+  {
+    if (i == position)
+    {
+      strip.setPixelColor(i, strip.Color(255, 0, 0));
+    }
+    else
+    {
+      strip.setPixelColor(i, strip.Color(0, 0, 255));
+    }
+  }
+  strip.show();
+}
diff --git a/Examples/Pinouts/ATmega328-Pinout-1.jpeg b/Examples/Pinouts/ATmega328-Pinout-1.jpeg
new file mode 100644 (file)
index 0000000..5f8cf04
Binary files /dev/null and b/Examples/Pinouts/ATmega328-Pinout-1.jpeg differ
diff --git a/Examples/Pinouts/ATmega328-Pinout-2.png b/Examples/Pinouts/ATmega328-Pinout-2.png
new file mode 100644 (file)
index 0000000..f418f85
Binary files /dev/null and b/Examples/Pinouts/ATmega328-Pinout-2.png differ
diff --git a/Examples/Pinouts/Arduino-Uno-Pin-Diagram-2.png b/Examples/Pinouts/Arduino-Uno-Pin-Diagram-2.png
new file mode 100644 (file)
index 0000000..ee86ee9
Binary files /dev/null and b/Examples/Pinouts/Arduino-Uno-Pin-Diagram-2.png differ
diff --git a/Examples/Pinouts/Arduino-Uno-Pin-Diagram-3.png b/Examples/Pinouts/Arduino-Uno-Pin-Diagram-3.png
new file mode 100644 (file)
index 0000000..670933f
Binary files /dev/null and b/Examples/Pinouts/Arduino-Uno-Pin-Diagram-3.png differ
diff --git a/Examples/Pinouts/Arduino-Uno-Pin-Diagram-4.png b/Examples/Pinouts/Arduino-Uno-Pin-Diagram-4.png
new file mode 100644 (file)
index 0000000..cd5fede
Binary files /dev/null and b/Examples/Pinouts/Arduino-Uno-Pin-Diagram-4.png differ
diff --git a/Examples/Pinouts/Arduino-Uno-Pin-Diagram.png b/Examples/Pinouts/Arduino-Uno-Pin-Diagram.png
new file mode 100644 (file)
index 0000000..74e2241
Binary files /dev/null and b/Examples/Pinouts/Arduino-Uno-Pin-Diagram.png differ
diff --git a/Examples/Pinouts/Arduino-Uno-Pinout-Digital-Pins.jpg b/Examples/Pinouts/Arduino-Uno-Pinout-Digital-Pins.jpg
new file mode 100644 (file)
index 0000000..132303a
Binary files /dev/null and b/Examples/Pinouts/Arduino-Uno-Pinout-Digital-Pins.jpg differ
diff --git a/Examples/TUES-LED_strip_1/TUES-LED_strip_1.ino b/Examples/TUES-LED_strip_1/TUES-LED_strip_1.ino
new file mode 100644 (file)
index 0000000..2426e6a
--- /dev/null
@@ -0,0 +1,132 @@
+#include <Adafruit_NeoPixel.h>
+#include <inttypes.h>
+
+#define NUM_PIXELS 16
+
+#define TOP_ROW 4
+#define MID_ROW 3
+#define BOT_ROW 2
+
+#define PPM_HEADER_LENGHT 58
+#define IMAGE_FILE_LENGHT 202
+
+/*
+typedef enum {RED, GREEN, BLUE, YELLOW, MAGENTA, CYAN} simple_color_t;
+int display_enum(simple_color_t buff[]);
+*/
+
+int render_image(uint8_t buff[3][NUM_PIXELS][3], const uint8_t image[]);
+int display_rgb(uint8_t buff[3][NUM_PIXELS][3]);
+
+const uint8_t image_data_0[IMAGE_FILE_LENGHT] =
+{
+  0x50, 0x36, 0x0a, 0x23, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20,
+  0x47, 0x49, 0x4d, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x32, 0x2e, 0x31,
+  0x30, 0x2e, 0x32, 0x32, 0x20, 0x50, 0x4e, 0x4d, 0x20, 0x70, 0x6c, 0x75, 0x67, 0x2d, 0x69, 0x6e,
+  0x0a, 0x31, 0x36, 0x20, 0x33, 0x0a, 0x32, 0x35, 0x35, 0x0a, 0xb9, 0x78, 0x90, 0xbc, 0x7b, 0x93,
+  0xbe, 0x7e, 0x98, 0xbe, 0x7e, 0x98, 0xbc, 0x7d, 0x98, 0xba, 0x7b, 0x96, 0xb8, 0x79, 0x96, 0xb4,
+  0x75, 0x92, 0xb1, 0x72, 0x8f, 0xaf, 0x70, 0x8d, 0xab, 0x6c, 0x89, 0xa7, 0x68, 0x85, 0xa2, 0x61,
+  0x7f, 0x9c, 0x5b, 0x79, 0x9a, 0x57, 0x76, 0x9b, 0x56, 0x75, 0xb8, 0x77, 0x8f, 0xbb, 0x7a, 0x92,
+  0xbc, 0x7c, 0x96, 0xbc, 0x7c, 0x96, 0xbb, 0x7b, 0x96, 0xb9, 0x79, 0x94, 0xb5, 0x76, 0x91, 0xb2,
+  0x73, 0x8e, 0xae, 0x6f, 0x8c, 0xac, 0x6d, 0x8a, 0xa4, 0x65, 0x82, 0xa0, 0x61, 0x7e, 0x9b, 0x5a,
+  0x78, 0x96, 0x55, 0x73, 0x94, 0x51, 0x70, 0x97, 0x52, 0x71, 0xb9, 0x75, 0x8c, 0xba, 0x79, 0x91,
+  0xbd, 0x7c, 0x94, 0xbb, 0x7b, 0x95, 0xba, 0x7a, 0x95, 0xb8, 0x78, 0x93, 0xb5, 0x75, 0x90, 0xb0,
+  0x71, 0x8c, 0xad, 0x6e, 0x8b, 0xaa, 0x6b, 0x88, 0xa3, 0x64, 0x81, 0xa0, 0x5f, 0x7d, 0x9b, 0x5a,
+  0x78, 0x97, 0x54, 0x73, 0x95, 0x52, 0x71, 0x99, 0x53, 0x75
+};
+
+const uint8_t image_data_1[IMAGE_FILE_LENGHT] = 
+{
+  0x50, 0x36, 0x0a, 0x23, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20,
+  0x47, 0x49, 0x4d, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x32, 0x2e, 0x31,
+  0x30, 0x2e, 0x32, 0x32, 0x20, 0x50, 0x4e, 0x4d, 0x20, 0x70, 0x6c, 0x75, 0x67, 0x2d, 0x69, 0x6e,
+  0x0a, 0x31, 0x36, 0x20, 0x33, 0x0a, 0x32, 0x35, 0x35, 0x0a, 0xb9, 0xa9, 0xd6, 0xb8, 0xa7, 0xd4,
+  0xba, 0xaa, 0xd7, 0xbd, 0xac, 0xd9, 0xbc, 0xab, 0xd8, 0xbc, 0xab, 0xd7, 0xba, 0xa9, 0xd5, 0xb5,
+  0xa4, 0xd0, 0xaf, 0x9e, 0xca, 0x98, 0x89, 0xb2, 0x8d, 0x7e, 0xa5, 0x7c, 0x6d, 0x94, 0x70, 0x62,
+  0x86, 0x6b, 0x5d, 0x80, 0x6c, 0x5e, 0x81, 0x6e, 0x60, 0x81, 0xb9, 0xac, 0xd8, 0xc2, 0xb2, 0xdf,
+  0xbe, 0xb1, 0xdd, 0xbd, 0xad, 0xda, 0xbb, 0xae, 0xda, 0xba, 0xad, 0xd9, 0xb7, 0xaa, 0xd6, 0xb2,
+  0xa5, 0xd1, 0xae, 0xa1, 0xcc, 0x9d, 0x8e, 0xb7, 0x8f, 0x80, 0xa7, 0x80, 0x72, 0x96, 0x77, 0x69,
+  0x8d, 0x72, 0x64, 0x87, 0x6e, 0x60, 0x83, 0x6c, 0x5e, 0x7f, 0xbe, 0xb1, 0xdd, 0xc4, 0xb7, 0xe3,
+  0xc2, 0xb5, 0xe1, 0xc1, 0xb4, 0xe0, 0xc0, 0xb3, 0xdf, 0xbe, 0xb3, 0xde, 0xbb, 0xb0, 0xdb, 0xb7,
+  0xac, 0xd7, 0xb3, 0xa8, 0xd2, 0xa0, 0x91, 0xba, 0x93, 0x84, 0xab, 0x83, 0x75, 0x99, 0x78, 0x6a,
+  0x8e, 0x72, 0x64, 0x87, 0x6d, 0x5f, 0x82, 0x6b, 0x5d, 0x7e
+};
+
+const uint8_t image_data_2[] =
+{
+  0x50, 0x36, 0x0a, 0x23, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20,
+  0x47, 0x49, 0x4d, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x32, 0x2e, 0x31,
+  0x30, 0x2e, 0x32, 0x32, 0x20, 0x50, 0x4e, 0x4d, 0x20, 0x70, 0x6c, 0x75, 0x67, 0x2d, 0x69, 0x6e,
+  0x0a, 0x31, 0x36, 0x20, 0x33, 0x0a, 0x32, 0x35, 0x35, 0x0a, 0x1a, 0x0a, 0xfe, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x1a, 0x0a, 0xfe, 0x1a, 0x0a, 0xfe, 0x1a, 0x0a, 0xfe, 0x00, 0x00, 0x00, 0x1a,
+  0x0a, 0xfe, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x1f, 0xee, 0x1d, 0x00, 0x00,
+  0x00, 0x1f, 0xee, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x0a, 0xfe, 0x04, 0x04, 0x04,
+  0x00, 0x00, 0x00, 0x1a, 0x0a, 0xfe, 0x00, 0x00, 0x00, 0x1a, 0x0a, 0xfe, 0x00, 0x00, 0x00, 0x1a,
+  0x0a, 0xfe, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0xdd, 0xfa, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0xdd, 0xfa, 0x03, 0x00, 0x00, 0x00, 0x1a, 0x0a, 0xfe, 0x1a, 0x0a, 0xfe,
+  0x00, 0x00, 0x00, 0x1a, 0x0a, 0xfe, 0x1a, 0x0a, 0xfe, 0x1a, 0x0a, 0xfe, 0x00, 0x00, 0x00, 0x1a,
+  0x0a, 0xfe, 0x1a, 0x0a, 0xfe, 0x00, 0x00, 0x00, 0xdd, 0xfa, 0x03, 0xdd, 0xfa, 0x03, 0xdd, 0xfa,
+  0x03, 0xdd, 0xfa, 0x03, 0xdd, 0xfa, 0x03, 0x00, 0x00, 0x00
+};
+
+Adafruit_NeoPixel top_row(NUM_PIXELS, TOP_ROW, NEO_GRB);
+Adafruit_NeoPixel mid_row(NUM_PIXELS, MID_ROW, NEO_GRB);
+Adafruit_NeoPixel bot_row(NUM_PIXELS, BOT_ROW, NEO_GRB);
+
+void setup()
+{
+    pinMode(TOP_ROW, OUTPUT);
+    pinMode(MID_ROW, OUTPUT);
+    pinMode(BOT_ROW, OUTPUT);
+    
+    // LED strip initialization
+    top_row.begin();
+    mid_row.begin();
+    bot_row.begin();
+}
+
+void loop()
+{
+    uint8_t frame_buffer[3][NUM_PIXELS][3] = {{{0}}};
+    render_image(frame_buffer, image_data_2);
+    display_rgb(frame_buffer);
+}
+
+int render_image(uint8_t buff[3][NUM_PIXELS][3], const uint8_t image[])
+{
+    if (buff == NULL || image == NULL)
+        return -1;
+  
+    for (uint8_t row = 0; row < 3; row++)
+    {
+        for (uint8_t col = 0; col < NUM_PIXELS; col++)
+        {
+            for (uint8_t i = 0; i < 3; i++)
+            {
+                buff[row][col][i] = image[PPM_HEADER_LENGHT + row * NUM_PIXELS * 3 + col * 3 + i];
+            }
+        }
+    }
+  
+    return 0;
+}
+
+int display_rgb(uint8_t buff[3][NUM_PIXELS][3])
+{
+    if (buff == NULL)
+        return -1;
+  
+    for (uint8_t col; col < NUM_PIXELS; col++)
+    {
+        top_row.setPixelColor(col, top_row.Color(buff[0][col][0], buff[0][col][1], buff[0][col][2]));
+        mid_row.setPixelColor(col, mid_row.Color(buff[1][col][0], buff[1][col][1], buff[1][col][2]));
+        bot_row.setPixelColor(col, bot_row.Color(buff[2][col][0], buff[2][col][1], buff[2][col][2]));
+    }
+  
+    top_row.show();
+    mid_row.show();
+    bot_row.show();
+  
+    return 0;
+}
diff --git a/Examples/TUES-LED_strip_1/TUES-LED_strip_1.png b/Examples/TUES-LED_strip_1/TUES-LED_strip_1.png
new file mode 100644 (file)
index 0000000..fd314f7
Binary files /dev/null and b/Examples/TUES-LED_strip_1/TUES-LED_strip_1.png differ
diff --git a/Examples/TUES-LED_strip_1/WS2812B.pdf b/Examples/TUES-LED_strip_1/WS2812B.pdf
new file mode 100644 (file)
index 0000000..4925af6
Binary files /dev/null and b/Examples/TUES-LED_strip_1/WS2812B.pdf differ
diff --git a/Examples/TUES-LED_strip_1/mona_lisa.ppm b/Examples/TUES-LED_strip_1/mona_lisa.ppm
new file mode 100644 (file)
index 0000000..2be5d2a
Binary files /dev/null and b/Examples/TUES-LED_strip_1/mona_lisa.ppm differ
diff --git a/Examples/TUES-LED_strip_1/nozdra.ppm b/Examples/TUES-LED_strip_1/nozdra.ppm
new file mode 100644 (file)
index 0000000..dbbd1b3
--- /dev/null
@@ -0,0 +1,5 @@
+P6
+# Created by GIMP version 2.10.22 PNM plug-in
+16 3
+255
+¹x\90¼{\93¾~\98¾~\98¼}\98º{\96¸y\96´u\92±r\8f¯p\8d«l\89§h\85¢a\7f\9c[y\9aWv\9bVu¸w\8f»z\92¼|\96¼|\96»{\96¹y\94µv\91²s\8e®o\8c¬m\8a¤e\82 a~\9bZx\96Us\94Qp\97Rq¹u\8cºy\91½|\94»{\95ºz\95¸x\93µu\90°q\8c­n\8bªk\88£d\81 _}\9bZx\97Ts\95Rq\99Su
\ No newline at end of file
diff --git a/Examples/TUES-LED_strip_1/rick_astley.jpg b/Examples/TUES-LED_strip_1/rick_astley.jpg
new file mode 100644 (file)
index 0000000..fd8e530
Binary files /dev/null and b/Examples/TUES-LED_strip_1/rick_astley.jpg differ
diff --git a/Examples/TUES-LED_strip_1/sako.ppm.txt b/Examples/TUES-LED_strip_1/sako.ppm.txt
new file mode 100644 (file)
index 0000000..c3967d2
--- /dev/null
@@ -0,0 +1,13 @@
+0x50, 0x36, 0x0a, 0x23, 0x20, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20,
+0x47, 0x49, 0x4d, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x32, 0x2e, 0x31,
+0x30, 0x2e, 0x32, 0x32, 0x20, 0x50, 0x4e, 0x4d, 0x20, 0x70, 0x6c, 0x75, 0x67, 0x2d, 0x69, 0x6e,
+0x0a, 0x31, 0x36, 0x20, 0x33, 0x0a, 0x32, 0x35, 0x35, 0x0a, 0xb9, 0xa9, 0xd6, 0xb8, 0xa7, 0xd4,
+0xba, 0xaa, 0xd7, 0xbd, 0xac, 0xd9, 0xbc, 0xab, 0xd8, 0xbc, 0xab, 0xd7, 0xba, 0xa9, 0xd5, 0xb5,
+0xa4, 0xd0, 0xaf, 0x9e, 0xca, 0x98, 0x89, 0xb2, 0x8d, 0x7e, 0xa5, 0x7c, 0x6d, 0x94, 0x70, 0x62,
+0x86, 0x6b, 0x5d, 0x80, 0x6c, 0x5e, 0x81, 0x6e, 0x60, 0x81, 0xb9, 0xac, 0xd8, 0xc2, 0xb2, 0xdf,
+0xbe, 0xb1, 0xdd, 0xbd, 0xad, 0xda, 0xbb, 0xae, 0xda, 0xba, 0xad, 0xd9, 0xb7, 0xaa, 0xd6, 0xb2,
+0xa5, 0xd1, 0xae, 0xa1, 0xcc, 0x9d, 0x8e, 0xb7, 0x8f, 0x80, 0xa7, 0x80, 0x72, 0x96, 0x77, 0x69,
+0x8d, 0x72, 0x64, 0x87, 0x6e, 0x60, 0x83, 0x6c, 0x5e, 0x7f, 0xbe, 0xb1, 0xdd, 0xc4, 0xb7, 0xe3,
+0xc2, 0xb5, 0xe1, 0xc1, 0xb4, 0xe0, 0xc0, 0xb3, 0xdf, 0xbe, 0xb3, 0xde, 0xbb, 0xb0, 0xdb, 0xb7,
+0xac, 0xd7, 0xb3, 0xa8, 0xd2, 0xa0, 0x91, 0xba, 0x93, 0x84, 0xab, 0x83, 0x75, 0x99, 0x78, 0x6a,
+0x8e, 0x72, 0x64, 0x87, 0x6d, 0x5f, 0x82, 0x6b, 0x5d, 0x7e
\ No newline at end of file
diff --git a/Examples/Timer_1_10kHz_ISR/Timer_1_10kHz_ISR.ino b/Examples/Timer_1_10kHz_ISR/Timer_1_10kHz_ISR.ino
new file mode 100644 (file)
index 0000000..b1ae812
--- /dev/null
@@ -0,0 +1,43 @@
+void setup() {
+  pinMode(13, OUTPUT);
+  noInterrupts(); //cli(); // Stop reception of interrupts
+
+  // Set PB1 to be an output (Pin9 Arduino UNO)
+  DDRB |= (1 << PB1);
+  // Clear Timer/Counter Control Registers
+  TCCR1A = 0;
+  TCCR1B = 0;
+  TIMSK1 = 0;
+  // Set non-inverting mode - Table 15-3 (page 108)
+  TCCR1A |= (1 << COM1A1);
+  // Set Fast-PWM Mode (Mode 14) - Table 15-5 (page 109)
+  TCCR1A |= (1 << WGM11);
+  TCCR1B |= (1 << WGM12);
+  TCCR1B |= (1 << WGM13);
+  // Clear Timer 1 Counter
+  TCNT1  = 0;
+  // Set PWM frequency/top value - Output PWM 10kHz
+  ICR1 = 199;
+  OCR1A = 180;
+  // Enable compare match interrupt
+  TIMSK1 |= (1 << OCIE1A);
+  TIMSK1 |= (1 << TOIE1);
+  // Set prescaler to 8 and starts PWM
+  TCCR1B |= (1 << CS11);
+
+  interrupts(); //sei();
+}
+
+void loop() {
+  // Empty
+}
+
+//Timer1 Compare Match Interrupt turns OFF pin 13 (LED)
+ISR(TIMER1_COMPA_vect) {
+  digitalWrite(13, LOW);
+}
+
+//Timer1 Overflow Interrupt turns ON pin 13 (LED)
+ISR(TIMER1_OVF_vect) {
+  digitalWrite(13, HIGH);
+}
diff --git a/Examples/Timer_ISR/Timer_ISR.ino b/Examples/Timer_ISR/Timer_ISR.ino
new file mode 100644 (file)
index 0000000..8d11733
--- /dev/null
@@ -0,0 +1,38 @@
+volatile boolean toggle1 = 0;
+
+void setup() {
+  pinMode(13, OUTPUT);
+  noInterrupts(); //cli(); // Stop reception of interrupts
+
+  // Set Timer 1 Control registers and counter to 0
+  TCCR1A = 0;
+  TCCR1B = 0;
+  TCNT1  = 0;
+
+  // Set compare match value = Fclk_io / (Fout * Prescaler) - 1
+  OCR1A = 15624; // = (16MHz) / (1 * 1024) - 1
+  TIMSK1 |= (1 << OCIE1A); // Enable compare match interrupt
+
+  // Set Timer 1 Mode of operation and clock prescalers
+  TCCR1B |= (1 << WGM12); // Mode 4
+  TCCR1B |= (1 << CS12) | (1 << CS10); // Set prescaler to 1024 (=> enable the clock)
+  
+  
+  interrupts(); //sei();
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+}
+
+ISR(TIMER1_COMPA_vect){//timer1 interrupt 1Hz toggles pin 13 (LED)
+//generates pulse wave of frequency 1Hz/2 = 0.5kHz (takes two cycles for full wave- toggle high then toggle low)
+  if (toggle1){
+    digitalWrite(13,HIGH);
+    toggle1 = 0;
+  }
+  else{
+    digitalWrite(13,LOW);
+    toggle1 = 1;
+  }
+}
diff --git a/Examples/UART-Send/UART-Send.ino b/Examples/UART-Send/UART-Send.ino
new file mode 100644 (file)
index 0000000..d6b3048
--- /dev/null
@@ -0,0 +1,17 @@
+void setup() {
+  // put your setup code here, to run once:
+  Serial.begin(9600);
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  Serial.print('V');
+  Serial.println('V');
+  
+  Serial.write(0x56);
+  while(Serial.available() > 0)
+  {
+    Serial.read();
+  }
+  delay(5000);
+}
diff --git a/Examples/external_interrupt/external_interrupt.ino b/Examples/external_interrupt/external_interrupt.ino
new file mode 100644 (file)
index 0000000..5ea877d
--- /dev/null
@@ -0,0 +1,47 @@
+#define BTN_PIN  2
+#define LED_PIN 13
+
+void button_pressed_ISR(void);
+void slow_computation(void);
+
+volatile uint8_t led_state = 0;
+
+void setup()
+{
+    pinMode(BTN_PIN, INPUT_PULLUP);
+    pinMode(LED_PIN, OUTPUT);
+  attachInterrupt(digitalPinToInterrupt(BTN_PIN), button_pressed_ISR, FALLING);
+  //attachInterrupt(digitalPinToInterrupt(BTN_PIN), button_pressed_ISR, RISING);
+  //attachInterrupt(digitalPinToInterrupt(BTN_PIN), button_pressed_ISR, CHANGE);
+  
+    Serial.begin(9600);
+}
+
+void loop()
+{
+    slow_computation();
+    
+    if (led_state)
+    Serial.println("LED in on.");
+    else
+    Serial.println("LED in off.");
+}
+
+void button_pressed_ISR(void)
+{
+    if (led_state)
+  {
+    led_state = 0;
+    digitalWrite(LED_PIN, LOW);
+  }
+  else
+  {
+    led_state = 1;
+    digitalWrite(LED_PIN, HIGH);
+  }
+}
+
+void slow_computation(void)
+{
+    delay(5000);
+}
diff --git a/Examples/external_interrupt/external_interrupt.png b/Examples/external_interrupt/external_interrupt.png
new file mode 100644 (file)
index 0000000..2d29e5c
Binary files /dev/null and b/Examples/external_interrupt/external_interrupt.png differ