Skip to content

Instantly share code, notes, and snippets.

View careyi3's full-sized avatar

Ian Carey careyi3

View GitHub Profile
@careyi3
careyi3 / README.md
Last active April 19, 2025 14:22
Arduino PID Implementation

Arduino PID

This is a basic implementation of a PID controller on an Arduino.

system_diagram

To replicate this, wire up the system as shown below:

system_diagram

@careyi3
careyi3 / README.md
Last active November 2, 2022 15:28
**THIS IS THE OLD CODE, NEW CODE HERE: https://github.com/careyi3/rover ** Autonomous Rover code: https://youtu.be/fp2pbrHLsrE

Rover

**THIS IS THE OLD CODE, NEW CODE HERE: https://github.com/careyi3/rover **

To run as a service copy rover.service to the location /lib/systemd/system/. From here then run the following two commands.

sudo systemctl enable rover
sudo systemctl start rover
@careyi3
careyi3 / pendulum_bot.ino
Last active March 3, 2025 09:30
Code for the pendulum bot you can find here: https://youtu.be/UL99bJTtESk
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <AccelStepper.h>
#include <PID_v1.h>
#include <Encoder.h>
const bool inverted = false;
const int stepMode = 3;
const int stepModes[6][5] = {
{5, 1, 0, 0, 0},
@careyi3
careyi3 / self_balancing_robot.ino
Created July 18, 2022 17:12
Simple Arduino code for a two wheel self balancing robot https://youtu.be/aJHFEo97TYA
#include "Wire.h"
#include "Kalman.h"
const int MPU_ADDR = 0x68;
const double MICRO_SECOND = 1000000.00;
const double INTERVAL = 1000.0;
double dt, timer = 0.0;
double gyro_y_offset, accl_x_offset, accl_z_offset;
@careyi3
careyi3 / ps2_controller_arduino_interface.ino
Created July 5, 2022 15:24
Sample code for a nice abstraction layer around the excellent PsxNewLib for interfacing a PS2 controller with an Arduino.
#include <DigitalIO.h>
#include <PsxControllerHwSpi.h>
const byte PIN_PS2_ATT = 10;
PsxControllerHwSpi<PIN_PS2_ATT> psx;
boolean connected = false;
byte lxOld, lyOld, rxOld, ryOld;
PsxButtons oldButtons;
#include <AccelStepper.h>
const int speed = 700;
const double accl = 0.05;
AccelStepper stepper = AccelStepper(AccelStepper::DRIVER, DD3, DD2);
long prev_speed;
void setup()
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
static void Main(String[] args) {
string a = Console.ReadLine();
string b = Console.ReadLine();