Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today! (You will need to be logged into the store)
Official Members also get to use the forum ad-free - so kit up and join us!


 Helmet light control w/ Adafruit Pro Trinket

  • 0 Replies
  • 2204 Views

Bfahome


    *
  • 167
  • I'm sure it will all work out in the end!
Helmet light control w/ Adafruit Pro Trinket
« on: Nov 11, 2015, 01:14 PM »

Adafruit Pro Trinket - 5V 16MHz

It's basically an Arduino, but cheaper and slightly less powerful and versatile.

I've got it pinned to a breadboard in the basic configuration I plan on using, with it reading from a potentiometer (pin A4) and outputting to five LEDs (pins 3, 6, 9, 10, 11).  Here's the code, if anyone's interested:

Code: [Select]
int function = 1;

void setup() {
  pinMode(A4, INPUT);
  pinMode(3, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
 
  if (function == 1) {
    digitalWrite(3, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200) * 2);
    digitalWrite(3, LOW);
    digitalWrite(6, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200));
    digitalWrite(6, LOW);
    digitalWrite(11, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200));
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200));
    digitalWrite(10, LOW);
    digitalWrite(9, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200) * 2);
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200));
    digitalWrite(10, LOW);
    digitalWrite(11, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200));
    digitalWrite(11, LOW);
    digitalWrite(6, HIGH);
    delay(map(analogRead(A4), 0, 1023, 30, 200));
    digitalWrite(6, LOW);
  }

  else if (function == 2) {
    analogWrite(3, map(analogRead(A4), 0, 1023, 2, 255));
    delay(60);
    analogWrite(3, 0);
    analogWrite(6, map(analogRead(A4), 0, 1023, 2, 255));
    delay(30);
    analogWrite(6, 0);
    analogWrite(11, map(analogRead(A4), 0, 1023, 2, 255));
    delay(30);
    analogWrite(11, 0);
    analogWrite(10, map(analogRead(A4), 0, 1023, 2, 255));
    delay(30);
    analogWrite(10, 0);
    analogWrite(9, map(analogRead(A4), 0, 1023, 2, 255));
    delay(60);
    analogWrite(9, 0);
    analogWrite(10, map(analogRead(A4), 0, 1023, 2, 255));
    delay(30);
    analogWrite(10, 0);
    analogWrite(11, map(analogRead(A4), 0, 1023, 2, 255));
    delay(30);
    analogWrite(11, 0);
    analogWrite(6, map(analogRead(A4), 0, 1023, 2, 255));
    delay(30);
    analogWrite(6, 0);
  }
  else;

}

Right now I have it set up with a couple of different modes.  The first one, shown in the video, is the LEDs blinking in sequence back and forth at a speed controlled by the potentiometer reading.  The second is a constant-speed flashing where the potentiometer controls the LED brightness (I used PWM pins as the LED pins).  I plan on having a couple of buttons to other input pins as well, one to toggle between functions (a feature not implemented in the code yet) and maybe one to turn helmet fans on or off.

The potentiometer will be built into my helmet's right ear cap, along with the buttons, hopefully, and control five LEDs on the lower section of the cap.  I hope to have something that looks like a comm that can be tuned to intercept transmissions.


Logged
 


Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today! (You will need to be logged into the store)
Official Members also get to use the forum ad-free - so kit up and join us!



Powered by EzPortal
SMF spam blocked by CleanTalk