using GPI pins on an arduino to run a keyboard

 

#include <Keyboard.h>

// Define the GPIO pins for CTRL+A, CTRL+B, CTRL+C, and CTRL+D keys
#define A_PIN 2
#define B_PIN 3
#define C_PIN 4
#define D_PIN 5

void setup() {
// Set up the GPIO pins as inputs with pull-up resistors
pinMode(A_PIN, INPUT_PULLUP);
pinMode(B_PIN, INPUT_PULLUP);
pinMode(C_PIN, INPUT_PULLUP);
pinMode(D_PIN, INPUT_PULLUP);

// Initialize the keyboard library
Keyboard.begin();
}

void loop() {
// Check if the CTRL+A pin is pressed
if (digitalRead(A_PIN) == LOW) {
// Press and release the CTRL+A key combination
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(‘a’);
delay(50);
Keyboard.releaseAll();
}

// Check if the CTRL+B pin is pressed
if (digitalRead(B_PIN) == LOW) {
// Press and release the CTRL+B key combination
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(‘b’);
delay(50);
Keyboard.releaseAll();
}

// Check if the CTRL+C pin is pressed
if (digitalRead(C_PIN) == LOW) {
// Press and release the CTRL+C key combination
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(‘c’);
delay(50);
Keyboard.releaseAll();
}

// Check if the CTRL+D pin is pressed
if (digitalRead(D_PIN) == LOW) {
// Press and release the CTRL+D key combination
Keyboard.press(KEY_LEFT_CTRL);
Keyboard.press(‘d’);
delay(50);
Keyboard.releaseAll();
}

// Wait for a short period of time before checking the pins again
delay(10);
}

Arduino sketch – keyboard keys pressed with gpi

#include KEYBOARD.h

const int F9_PIN = 2;
const int F10_PIN = 3;
const int F9_LED_PIN = 4;
const int F10_LED_PIN = 5;

void setup() {
Keyboard.begin();
pinMode(F9_PIN, INPUT_PULLUP);
pinMode(F10_PIN, INPUT_PULLUP);
pinMode(F9_LED_PIN, OUTPUT);
pinMode(F10_LED_PIN, OUTPUT);
}

void loop() {
if (digitalRead(F9_PIN) == LOW) {
Keyboard.press(KEY_F9);
digitalWrite(F9_LED_PIN, HIGH);
delay(100);
Keyboard.release(KEY_F9);
digitalWrite(F9_LED_PIN, LOW);
}

if (digitalRead(F10_PIN) == LOW) {
Keyboard.press(KEY_F10);
digitalWrite(F10_LED_PIN, HIGH);
delay(100);
Keyboard.release(KEY_F10);
digitalWrite(F10_LED_PIN, LOW);
}
}

Python OSC device – Motarized fader for volume + mute switch and solo switch

import reapy
import OSC

# Create an OSC client to send messages to Reaper
client = OSC.OSCClient()
client.connect(("127.0.0.1", 8000))

# Create an OSC server to receive messages from the fader and switches
server = OSC.OSCServer(("127.0.0.1", 9000))

def handle_volume(path, tags, args, source):
volume = args[0]
# Set the volume of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.volume = volume
reapy.disconnect()

# Add a callback for the volume fader
server.addMsgHandler("/volume", handle_volume)

def handle_mute(path, tags, args, source):
mute = args[0]
# Set the mute of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.mute = mute
reapy.disconnect()

# Add a callback for the mute switch
server.addMsgHandler("/mute", handle_mute)

def handle_solo(path, tags, args, source):
solo = args[0]
# Set the solo of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.solo = solo
reapy.disconnect()

# Add a callback for the solo switch
server.addMsgHandler("/solo", handle_solo)

# Run the OSC server
st = threading.Thread(target=server.serve_forever)
st.start()

BESKAR2D2 – test board with RJ45

#include <ReefwingSBUS.h>
#define MIN_LEFT_ROLL    -255
#define MAX_LEFT_ROLL     255
#define MIN_LEFT_PITCH    -255
#define MAX_LEFT_PITCH     255
#define MIN_RIGHT_ROLL   -255
#define MAX_RIGHT_ROLL    255
#define MIN_RIGHT_PITCH   -255
#define MAX_LEFT_PITCH    255
#define MIN_SBUS          200
#define MAX_SBUS          1800
//#define SWITCH_ON         991
SBUS RX_from_RADIOLINK(Serial3);
uint16_t channels[16];
uint16_t lostFrameCtr = 0;
uint16_t sbusChannel6 = 0, sbusChannel7 = 0, sbusChannel8 = 0, sbusChannel5 = 0, rxMode = 0;
int16_t sbusChannel1 = 0, sbusChannel2 = 0, sbusChannel3 = 0, sbusChannel4 = 0;
bool failSafe;
bool lostFrame;
bool armed = false;
void setup() {
  //  Start Serial and wait for connection from computer
  Serial.begin(115200);
  while (!Serial);
  RX_from_RADIOLINK.begin();
//BLUE RJ45 WIRE A
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
//wHITE WIRE  RJ45 WIRE b
  pinMode(30, OUTPUT);
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);
//BLUE RJ45 WIRE B
  pinMode(34, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(36, OUTPUT);
  pinMode(37, OUTPUT);
//WHITE RJ45 WIRE B
  pinMode(38, OUTPUT);
  pinMode(39, OUTPUT);
  pinMode(40, OUTPUT);
  pinMode(41, OUTPUT);
//GREY RJ45 WIRE A
  pinMode(45, OUTPUT);//this is capable of PWM//speed
  pinMode(49, OUTPUT);//direction
  pinMode(50, OUTPUT);//BRAKE
  pinMode(51, OUTPUT);//STOP
//GREY RJ45 WIRE B
  pinMode(44, OUTPUT);//this is capable of PWM  //SPEED
  pinMode(48, OUTPUT);//DIRECTION
  pinMode(46, OUTPUT);//BRAKE
  pinMode(47, OUTPUT);//STOP
}
void loop() {
  // Check for a valid SBUS packet from the RX_from_RADIOLINK receiver
  if (RX_from_RADIOLINK.read(&channels[0], &failSafe, &lostFrame)) {
   //Scale the joysticks to the min and max
    sbusChannel1 = map(channels[0], MIN_SBUS, MAX_SBUS, MIN_LEFT_ROLL, MAX_LEFT_ROLL);
    sbusChannel2  = map(channels[1], MIN_SBUS, MAX_SBUS,  MAX_LEFT_PITCH,MIN_LEFT_PITCH);
    sbusChannel4 = map(channels[3], MIN_SBUS, MAX_SBUS, MIN_RIGHT_PITCH, MAX_LEFT_PITCH);
    sbusChannel3 = map(channels[2], MIN_SBUS, MAX_SBUS, MIN_RIGHT_ROLL, MAX_RIGHT_ROLL);
    //  AUX Channels
    sbusChannel5 = channels[4];
    sbusChannel6     = channels[5];
    sbusChannel7    = channels[6];
    sbusChannel8    = channels[7];
    rxMode   = channels[8];
    if (lostFrame) { lostFrameCtr++; }
  //LEFT SWITCH
  switch (sbusChannel7) {
    case 200:
      Serial.print(“LS”);Serial.print(“A”);Serial.print(“\t”);
                digitalWrite(31, HIGH);
                  digitalWrite(32, LOW);
                  digitalWrite(33, LOW);
            break;
    case 1000:
      Serial.print(“LS”);Serial.print(“B”);Serial.print(“\t”);
                   digitalWrite(31, LOW);
                  digitalWrite(32,HIGH);
                  digitalWrite(33, LOW);
      break;
    case 1800:
      Serial.print(“LS”);Serial.print(“C”);Serial.print(“\t”);
      digitalWrite(31, LOW);
                  digitalWrite(32, LOW);
                  digitalWrite(33, HIGH);
      break;
    default:
     Serial.println(“Invalid value”);
  }
/////////////////////////////// LEFT VOLUME
      Serial.print(“LV”);Serial.print(sbusChannel8); Serial.print(“\t”);
////LEFT X
        Serial.print(“LX”);Serial.print(sbusChannel4); Serial.print(“\t”);
      if (sbusChannel4 >= -255 && sbusChannel4 < -50) {
    // sbusChannel is within the range from -100 to -50
                  digitalWrite(38, HIGH);
                  digitalWrite(39, HIGH);
                  digitalWrite(40, LOW);
                  digitalWrite(41, LOW);
} else if (sbusChannel4 >= -50 && sbusChannel4 < -10) {
    // sbusChannel is within the range from -50 to -10
                   digitalWrite(38, HIGH);
                  digitalWrite(39, LOW);
                  digitalWrite(40, LOW);
                  digitalWrite(41, LOW);
} else if (sbusChannel4 >= -10 && sbusChannel4 < 10) {
    // sbusChannel is within the range from -10 to 10
                  digitalWrite(38, LOW);
                  digitalWrite(39, LOW);
                  digitalWrite(40, LOW);
                  digitalWrite(41, LOW);
} else if (sbusChannel4 >= 10 && sbusChannel4 < 50) {
    // sbusChannel is within the range from 10 to 50
                  digitalWrite(38, LOW);
                  digitalWrite(39, LOW);
                  digitalWrite(40, LOW);
                  digitalWrite(41, HIGH);
} else if (sbusChannel4 >= 50 && sbusChannel4 <= 255) {
    // sbusChannel is within the range from 50 to 100
                  digitalWrite(38, LOW);
                  digitalWrite(39, LOW);
                  digitalWrite(40, HIGH);
                  digitalWrite(41, HIGH);
} else {
    // sbusChannel is outside of all of the specified ranges
}
//////////////////////LEFT Y AXIS
    Serial.print(“LY”);Serial.print(sbusChannel3); Serial.print(“\t”);
      if (sbusChannel3 >= -255 && sbusChannel3 < -50) {
    // sbusChannel is within the range from -100 to -50
                  analogWrite(45,fabs(sbusChannel3) );//speed
                  digitalWrite(49, LOW);//direction
                  digitalWrite(50, LOW);//BRAKE
                  digitalWrite(51, LOW);//STOP//
Serial.print(“RF”);
} else if (sbusChannel3 >= -50 && sbusChannel3 < -10) {
    // sbusChannel is within the range from -50 to -10
                  analogWrite(45,fabs(sbusChannel1) );//speed
                  digitalWrite(49, LOW);//direction
                  digitalWrite(50, HIGH);//BRAKE
                  digitalWrite(51, LOW);//STOP//
Serial.print(“RS”);
} else if (sbusChannel3 >= -10 && sbusChannel3 < 10) {
    // sbusChannel is within the range from -10 to 10
                   analogWrite(45,fabs(sbusChannel3) );//speed
                  digitalWrite(49, LOW);//direction
                  digitalWrite(50, HIGH);//BRAKE
                  digitalWrite(51, HIGH);//STOP//
Serial.print(“SS”);
} else if (sbusChannel3 >= 10 && sbusChannel3 < 50) {
    // sbusChannel is within the range from 10 to 50
                  analogWrite(45,fabs(sbusChannel3) );//speed
                  digitalWrite(49, HIGH);//direction
                  digitalWrite(50, HIGH);//BRAKE
                  digitalWrite(51, LOW);//STOP//
Serial.print(“FS”);
} else if (sbusChannel3 >= 50 && sbusChannel3 <= 255) {
    // sbusChannel is within the range from 50 to 100
                  analogWrite(45,fabs(sbusChannel3) );//speed
                  digitalWrite(49, HIGH);//direction
                  digitalWrite(50, LOW);//BRAKE
                  digitalWrite(51, LOW);//STOP//
Serial.print(“FF”);
} else {
    // sbusChannel is outside of all of the specified ranges
}
 Serial.print(“\t”);
 Serial.print(“\t”);
 Serial.print(“\t”);
//////////////////////////////
//RIGHT SIDE OF CONTROLLER
/////////////////////////////
////////////////////////////////
    Serial.print(“RX”);Serial.print(sbusChannel1); Serial.print(“\t”);
      if (sbusChannel1 >= -255 && sbusChannel1 < -50) {
    // sbusChannel is within the range from -100 to -50
                  digitalWrite(34, HIGH);
                  digitalWrite(35, HIGH);
                  digitalWrite(36, LOW);
                  digitalWrite(37, LOW);
} else if (sbusChannel1 >= -50 && sbusChannel1 < -10) {
    // sbusChannel is within the range from -50 to -10
                   digitalWrite(34, HIGH);
                  digitalWrite(35, LOW);
                  digitalWrite(36, LOW);
                  digitalWrite(37, LOW);
} else if (sbusChannel1 >= -10 && sbusChannel1 < 10) {
    // sbusChannel is within the range from -10 to 10
digitalWrite(34, LOW);
                  digitalWrite(35, LOW);
                  digitalWrite(36, LOW);
                  digitalWrite(37, LOW);
} else if (sbusChannel1 >= 10 && sbusChannel1 < 50) {
    // sbusChannel is within the range from 10 to 50
    digitalWrite(34, LOW);
                  digitalWrite(35, LOW);
                  digitalWrite(36, LOW);
                  digitalWrite(37, HIGH);
} else if (sbusChannel1 >= 50 && sbusChannel1 <= 255) {
    // sbusChannel is within the range from 50 to 100
    digitalWrite(34, LOW);
                  digitalWrite(35, LOW);
                  digitalWrite(36, HIGH);
                  digitalWrite(37, HIGH);
} else {
    // sbusChannel is outside of all of the specified ranges
}
///////////////////////////////////////RIGHT Y
    Serial.print(“RY”);Serial.print(sbusChannel2); Serial.print(“\t”);
      if (sbusChannel2 >= -255 && sbusChannel2 < -50) {
    // sbusChannel is within the range from -100 to -50
                  analogWrite(44,fabs(sbusChannel2) );//speed
                  digitalWrite(48, LOW);//direction
                  digitalWrite(46, LOW);//BRAKE
                  digitalWrite(47, LOW);//STOP
Serial.print(“RF”);
} else if (sbusChannel2 >= -50 && sbusChannel2 < -10) {
    // sbusChannel is within the range from -50 to -10
                   analogWrite(44,fabs(sbusChannel2) );//speed
                  digitalWrite(48, LOW);//direction
                  digitalWrite(46, HIGH);//BRAKE
                  digitalWrite(47, LOW);//STOP
Serial.print(“RS”);
} else if (sbusChannel2 >= -10 && sbusChannel2 < 10) {
    // sbusChannel is within the range from -10 to 10
                  analogWrite(44,fabs(sbusChannel2) );//speed
                  digitalWrite(48, LOW);//direction
                  digitalWrite(46, HIGH);//BRAKE
                  digitalWrite(47, HIGH);//STOP
Serial.print(“ST”);
} else if (sbusChannel2 >= 10 && sbusChannel2 < 50) {
    // sbusChannel is within the range from 10 to 50
                  analogWrite(44,fabs(sbusChannel2) );//speed
                  digitalWrite(48, HIGH);//direction
                  digitalWrite(46, LOW);//BRAKE
                  digitalWrite(47, LOW);//STOP
                Serial.print(“FS”);
} else if (sbusChannel2 >= 50 && sbusChannel2 <= 255) {
    // sbusChannel is within the range from 50 to 100
                  analogWrite(44,fabs(sbusChannel2) );//speed
                  digitalWrite(48, HIGH);//direction
                  digitalWrite(46, LOW);//BRAKE
                  digitalWrite(47, LOW);//STOP
                  Serial.print(“FF”);
} else {
    // sbusChannel is outside of all of the specified ranges
}
Serial.print(“\t”);
     //Serial.print(“RB”);Serial.print(sbusChannel6); Serial.print(“\t”);
switch (sbusChannel6) {
    case 200:
      Serial.print(“RB”);Serial.print(“O”);Serial.print(“\t”);
                  digitalWrite(26, LOW);
                  digitalWrite(30, LOW);
            break;
    case 1800:
    Serial.print(“RB”);  Serial.print(“P”);Serial.print(“\t”);
                  digitalWrite(26, HIGH);
                      digitalWrite(30, HIGH);
      break;
    default:
      Serial.print(“RB”);Serial.print(“Invalid value”);Serial.print(“\t”);
      digitalWrite(26, LOW);
      digitalWrite(30, LOW);
      break;
  }
;
  switch (sbusChannel5) {
    case 200:
      Serial.print(“RS”);Serial.print(“A”);Serial.print(“\t”);
                  digitalWrite(27, HIGH);
                  digitalWrite(28, LOW);
                  digitalWrite(29, LOW);
                  break;
    case 1000:
      Serial.print(“RS”);Serial.print(“B”);Serial.print(“\t”);
                  digitalWrite(27, LOW);
                  digitalWrite(28,HIGH);
                  digitalWrite(29, LOW);
                  break;
    case 1800:
    Serial.print(“RS”);  Serial.print(“C”);Serial.print(“\t”);
                  digitalWrite(27, LOW);
                  digitalWrite(28, LOW);
                  digitalWrite(29, HIGH);
      break;
    default:
      Serial.print(“RS”);Serial.print(“Invalid value”);Serial.print(“\t”);
                        digitalWrite(27, LOW);
                  digitalWrite(28, LOW);
                  digitalWrite(29, LOW);
  }
;
Serial.print(“\t”);
       Serial.println(rxMode);
  }
  delay(10);
}

Arduino Project – Digitally Controlled Analog Surround Sound Panning – Open Source

For your enjoyment:

Digitally Controlled Analog Surround Sound Panning

 

Presentation:

 

Circuit Explination:

 

Presentation documents:

0 – TPJ – Technical Presentation

0 – TPJ556-FINAL report DCASSP-COMPLETE

0 – TPJ556-FINAL report DCASSP-SCHEMATICS V1

 

 

Project Source Code:

Continue reading

Fixing Logitech trackball performance

I love these Logitech Marble Mouse trackballs, I have one for every computer.  After a few years they slow down physically.  Cleaning the dust off does not help enough, something different needed to be applied.  I’ve been researching lubricants and oils, doing some tests with households; but I think I’ve found the perfect fluid.  Ian Gomes of Union Sound Company made a recommendation a few years back for Penny and Giles faders.  A quick amazon search lead me to Lucas Silicone Shock fluid.  I must report that it is the perfect product for this application.  If you need a drop, I’ll send you a q-tip of it in the mail.

IMG_0553

Generating Code with spreadsheet for Keyboard Assignments of CADSOFT Eagle

I needed a way of Generating Code, lots of code.   In cadsoft eagle, the Keyboard Assignments are completely user customizable.  They have a script language that allows you to modify the software.  I’ve used hundreds of the ULP and SCRs and decided to write my own Generator.

Necessity is the mother of all innovation.  Screen Shot 2015-09-14 at 12.56.34 AM Screen Shot 2015-09-14 at 12.56.45 AM Screen Shot 2015-09-14 at 12.56.52 AM Screen Shot 2015-09-14 at 12.56.59 AM Screen Shot 2015-09-14 at 12.57.04 AM Screen Shot 2015-09-14 at 12.58.37 AM Screen Shot 2015-09-14 at 12.58.44 AM Screen Shot 2015-09-14 at 12.58.50 AM

 

GREEN HOME MONITORING SYSTEM

Title: GREEN HOME MONITORING SYSTEM – TRANSMITTER
Author: ANTHONY P KUZUB
DATE: 2015 04 01
Description:

REMOTE MONITORING TRANSMITTER

The GREEN HOME MONITORING SYSTEM controls, monitors then transmits the
status of three room lights to a remote monitoring station.

The code below is the local control and transmitter

Three light switches along with motion sensors control the functionality
of the rooms lights.

When the system is enabled:
The light turns on When motion is detected.
Once motion is detected a five second counter Starts.
If motion is not detected within the five seconds The light shut
off saving power.

When the system is disabled:
The light switch controls The light Directly.

A Peak Power cost value is captured based on the time of day.
To Test this feature: apply a slowly 10mHz Sine wave 1.25
Vpp with offset of 0.625V offset to TP7

This moving sine wave is converted to digital by means of A/D convertor

This power cost value is displayed on the segment display
Indicating the value of power throughout the day.

The Status of The System state, switch position, motion detection, Light
status, and Energy cost, are transmitted to a remote monitoring station
via serial port 1.

 

0 - main 1- ZeroVariables 2 - DefineHardware 3 - SystemEnableCheck 4 - Power Sample 5 - Room 1 Check 6 - Room 2 Check 7 - Room 3 Check 8 - EncodeTransmissionData 9 - Transmit 10 - Diagnostics

 

 

TRANSMIT TRUTH TABLE

 

Title: GREEN HOME MONITORING SYSTEM – RECEIVER
Author: ANTHONY P KUZUB
DATE: 2015 04 01
Description:

The GREEN HOME MONITORING SYSTEM controls, monitors then transmits the
status of three room lights to a remote monitoring station.

The code below is the remote monitoring station

This program receives 2 bytes of data from the transmitter through
Serial port 1. The data is decoded and displayed on a screen by access
of serial port 2 of the controller.

A workstations TERMINAL session connects a a com port to the hardware receiver.

SESSION CONFIGURATION:
BAUD RATE: 9600
DATA BITS: 8
PARITY: NONE
FLOW CONTROL: NONE
EMULATION: ANSI

The Status of the system, switch positions, motion detection, Light status,
and Energy PEAK VALUE displayed on the terminal screen.

Screen Layout

A Changing Peak Power cost is applied proportionaly to room cost acumulators.

By Pressing the respective key on the terminal keyboard, the rooms cost will
reset to zero.

Please note that with the exception of the push buttons all states are
ACTIVE HIGH

 

0 - main 1 - ZeroVariable 2 - Initialize Devices 3 - Paint Screen 4 - Receive 5 - DecodeReceivedData 6 - KeyboardCheck 7 - ScreenUpdateStatus 8 - ScreenUpdateLight 9 - ScreenUpdateCost 10 - scr_writech 11 - KeyPress 12 - Diagnostics

 

SUCCESSIVE APPROXIMATION ADC CALCULATOR

Was working on my Micro controller reading and had a need for a calculator to check my work for Successive Approximation of Analog to Digital signals.

WIKIPEDIA:  A successive approximation ADC is a type of analog-to-digital converter that converts a continuous analog waveform into a discrete digital representation via a binary search through all possible quantization levels before finally converging upon a digital output for each conversion.


Screen Shot 2015-03-02 at 5.09.50 PM

Screen Shot 2015-03-02 at 5.21.55 PM


Screen Shot 2015-03-02 at 5.10.01 PM
Here is a Link to the excel calculator for your enjoyment