diff --git a/arm/armcode/armcode.ino b/arm/armcode/armcode.ino new file mode 100644 index 0000000..1f00230 --- /dev/null +++ b/arm/armcode/armcode.ino @@ -0,0 +1,58 @@ +#include + +SMS_STS st; + +// Changes position of servo with ID +void writePosition(int id, int position, int speed = 2500, int acceleration = 50) { + st.WritePosEx(id, position, speed, acceleration); +} + +// Reads position of servo with ID +int getPosition(int id) { + int pos = st.ReadPos(id); + return pos; +} + +// Prints position of servo with ID +void printPosition(int id) { + int pos = getPosition(id); + Serial.print("Current Position: "); + Serial.println(pos); +} + +// Serial Stuff. IDK +void setup() +{ + Serial.begin(115200); + Serial1.begin(1000000, SERIAL_8N1); + st.pSerial = &Serial1; + + delay(1000); +} + +void loop() +{ + writePosition(1, 4095); + delay(3000); + printPosition(1); + delay(1000); + + writePosition(2, 4095); + delay(3000); + printPosition(2); + delay(1000); + + writePosition(1, 0); + delay(3000); + printPosition(1); + delay(1000); + + writePosition(2, 0); + delay(3000); + printPosition(2); + delay(1000); + +} + +// V=60*0.732=43.92rpm A=50*8.7deg/s^2,P0=0, P1=4095 +// delay((4095-0)*1000/(60*50) + (60*50)*10/(50) + 50); //[(P1-P0)/(V*50)]*1000+[(V*50)/(A*100)]*1000 + 50 \ No newline at end of file diff --git a/keypad_pass_IO/keypad_test-GRR-2025/keypad_test/competition_keypad_code.ino b/keypad_pass_IO/keypad_test-GRR-2025/keypad_test/competition_keypad_code.ino new file mode 100644 index 0000000..6752010 --- /dev/null +++ b/keypad_pass_IO/keypad_test-GRR-2025/keypad_test/competition_keypad_code.ino @@ -0,0 +1,115 @@ +// Code used for Antenna 4 of the SoutheastCon Hardware Competition 2026 + +#include + +int red = 12; +int green = 7; +int blue = 6; +int led_pin = 13; + +int redBrightness = 0; +int greenBrightness = 0; +int blueBrightness = 0; +int randomColor; + +const int ROW_NUM = 4; //four rows +const int COLUMN_NUM = 3; //three columns + +char keys[ROW_NUM][COLUMN_NUM] = { + {'1','2','3'}, + {'4','5','6'}, + {'7','8','9'}, + {'*','0','#'} +}; + +byte pin_rows[ROW_NUM] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad +byte pin_column[COLUMN_NUM] = {8, 9, 10}; //connect to the column pinouts of the keypad + +Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM ); + +const String password = "73738"; // change your password here +String input_password; + +void setup(){ + Serial.begin(9600); + input_password.reserve(32); // maximum input characters is 33, change if needed + randomSeed(analogRead(A0)); + randomColor = random(4); + Serial.println(randomColor); + + pinMode(red, OUTPUT); + pinMode(green, OUTPUT); + pinMode(blue, OUTPUT); + pinMode(led_pin, OUTPUT); + +} + +void loop(){ + char key = keypad.getKey(); + + if (key){ + + if(key == '*') { + Serial.println("* pressed. Clearing password and turning LEDs off..."); + input_password = ""; // clear input password + analogWrite(red, 0); + analogWrite(green, 0); + analogWrite(blue, 0); + digitalWrite(led_pin, LOW); + Serial.println("Password cleared. LEDs off."); + } + else if(key == '#') { + Serial.println("# pressed. Checking password..."); + if(password == input_password) { + Serial.println("password is correct!"); + Serial.print("Color (0: red, 1: blue, 2: green, 3: purple): "); + Serial.println(randomColor); + + Serial.println("LED On."); + digitalWrite(led_pin, HIGH); + + if(randomColor == 0) + { + redBrightness = 150; + blueBrightness = 0; + greenBrightness = 0; + } + else if(randomColor == 1) + { + redBrightness = 0; + blueBrightness = 150; + greenBrightness = 0; + } + else if(randomColor == 2) + { + redBrightness = 0; + blueBrightness = 0; + greenBrightness = 150; + } + else + { + redBrightness = 200; + blueBrightness = 150; + greenBrightness = 0; + } + + analogWrite(red, redBrightness); + analogWrite(green, greenBrightness); + analogWrite(blue, blueBrightness); + digitalWrite(led_pin, HIGH); + delay(200); + input_password = ""; // clear input password + } + else { + Serial.println("password is incorrect, try again"); + input_password = ""; // clear input password + } + } + else { + Serial.print("Key: "); + Serial.println(key); + input_password += key; // append new character to input password string + Serial.println("Current Input Password:" + input_password); + } + } +} \ No newline at end of file diff --git a/keypad_pass_IO/keypad_test-GRR-2025/keypad_test/keypad_test.ino b/keypad_pass_IO/keypad_test-GRR-2025/keypad_test/keypad_test.ino index 76f638a..4804184 100644 --- a/keypad_pass_IO/keypad_test-GRR-2025/keypad_test/keypad_test.ino +++ b/keypad_pass_IO/keypad_test-GRR-2025/keypad_test/keypad_test.ino @@ -1,104 +1,104 @@ -// Use this example with the Adafruit Keypad products. -// You'll need to know the Product ID for your keypad. -// Here's a summary: -// * PID3844 4x4 Matrix Keypad -// * PID3845 3x4 Matrix Keypad -// * PID1824 3x4 Phone-style Matrix Keypad -// * PID1332 Membrane 1x4 Keypad -// * PID419 Membrane 3x4 Matrix Keypad +// // Use this example with the Adafruit Keypad products. +// // You'll need to know the Product ID for your keypad. +// // Here's a summary: +// // * PID3844 4x4 Matrix Keypad +// // * PID3845 3x4 Matrix Keypad +// // * PID1824 3x4 Phone-style Matrix Keypad +// // * PID1332 Membrane 1x4 Keypad +// // * PID419 Membrane 3x4 Matrix Keypad -#include "Adafruit_Keypad.h" +// #include "Adafruit_Keypad.h" -// define your specific keypad here via PID -#define KEYPAD_PID3844 -// define your pins here -// can ignore ones that don't apply -#define R1 2 -#define R2 3 -#define R3 4 -#define R4 5 -#define C1 8 -#define C2 9 -#define C3 10 -#define C4 11 -#define red 12 -#define green 7 -#define blue 6 -#define greenLED 13 -#define bitter e.bit +// // define your specific keypad here via PID +// #define KEYPAD_PID3844 +// // define your pins here +// // can ignore ones that don't apply +// #define R1 2 +// #define R2 3 +// #define R3 4 +// #define R4 5 +// #define C1 8 +// #define C2 9 +// #define C3 10 +// #define C4 11 +// #define red 12 +// #define green 7 +// #define blue 6 +// #define greenLED 13 +// #define bitter e.bit -// leave this import after the above configuration -#include "keypad_config.h" +// // leave this import after the above configuration +// #include "keypad_config.h" -String pass = "73738#"; // Correct input expected. -String progress = ""; // Keeps track of what keys have been inputted. +// String pass = "73738#"; // Correct input expected. +// String progress = ""; // Keeps track of what keys have been inputted. -//initialize an instance of class NewKeypad -Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); +// //initialize an instance of class NewKeypad +// Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS); -void setup() { - Serial.begin(9600); - customKeypad.begin(); - pinMode(12, OUTPUT); - pinMode(7, OUTPUT); - pinMode(6, OUTPUT); - pinMode(13, OUTPUT); - randomSeed(analogRead(0)); -} +// void setup() { +// Serial.begin(9600); +// customKeypad.begin(); +// pinMode(12, OUTPUT); +// pinMode(7, OUTPUT); +// pinMode(6, OUTPUT); +// pinMode(13, OUTPUT); +// randomSeed(analogRead(0)); +// } -void colorSetter(uint8_t red_state, uint8_t green_state, uint8_t blue_state) -{ - digitalWrite(red, red_state); - digitalWrite(green, green_state); - digitalWrite(blue, blue_state); -} +// void colorSetter(uint8_t red_state, uint8_t green_state, uint8_t blue_state) +// { +// digitalWrite(red, red_state); +// digitalWrite(green, green_state); +// digitalWrite(blue, blue_state); +// } -void loop() { - // Main code that runs repeatedly: - customKeypad.tick(); +// void loop() { +// // Main code that runs repeatedly: +// customKeypad.tick(); - while(customKeypad.available()){ - keypadEvent e = customKeypad.read(); // Reads most recent keypad event. +// while(customKeypad.available()){ +// keypadEvent e = customKeypad.read(); // Reads most recent keypad event. - if (progress.length() >= 6) // When progress equals length of correct code... - { - if (progress == pass) // Checking if progress equals the correct code. - { - Serial.println("SUCCESS!"); - int rand = random(1, 5); // Generates a random number between 1 and 4. - switch (rand) { - case 1: // Red - colorSetter(HIGH, LOW, LOW); - break; - case 2: // Green - colorSetter(LOW, HIGH, LOW); - break; - case 3: - colorSetter(LOW, LOW, HIGH); - break; - case 4: //Purple - colorSetter(HIGH, LOW, HIGH); - break; - } - digitalWrite(greenLED, HIGH); - } - else - { - Serial.println("FAIL!"); - } - progress = ""; // Reset progress for next attempt. - delay(1000); // LED stays on for 1 second before turning back off for standby. - colorSetter(LOW, LOW, LOW); // off - digitalWrite(greenLED, LOW); - } +// if (progress.length() >= 6) // When progress equals length of correct code... +// { +// if (progress == pass) // Checking if progress equals the correct code. +// { +// Serial.println("SUCCESS!"); +// int rand = random(1, 5); // Generates a random number between 1 and 4. +// switch (rand) { +// case 1: // Red +// colorSetter(HIGH, LOW, LOW); +// break; +// case 2: // Green +// colorSetter(LOW, HIGH, LOW); +// break; +// case 3: +// colorSetter(LOW, LOW, HIGH); +// break; +// case 4: //Purple +// colorSetter(HIGH, LOW, HIGH); +// break; +// } +// digitalWrite(greenLED, HIGH); +// } +// else +// { +// Serial.println("FAIL!"); +// } +// progress = ""; // Reset progress for next attempt. +// delay(1000); // LED stays on for 1 second before turning back off for standby. +// colorSetter(LOW, LOW, LOW); // off +// digitalWrite(greenLED, LOW); +// } - if (bitter.EVENT == KEY_JUST_PRESSED) // If most recent event is a button pressed... - { - progress += (char)bitter.KEY; // Cast the key pressed to a char and add to progress. - Serial.println(progress); // Print current progress for debugging. - } - } +// if (bitter.EVENT == KEY_JUST_PRESSED) // If most recent event is a button pressed... +// { +// progress += (char)bitter.KEY; // Cast the key pressed to a char and add to progress. +// Serial.println(progress); // Print current progress for debugging. +// } +// } - delay(10); -} \ No newline at end of file +// delay(10); +// } \ No newline at end of file