This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 0 = 0 | |
* 1 = 25% forward | |
* 2 = 50% forward | |
* 3 = 75% forward | |
* 4 = 100% forward | |
* 5 = 0 back | |
* 6 = 25% back | |
* 7 = 50% back | |
* 8 = 75% back |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<plib.h> | |
int i; | |
//Interrupt Functions | |
void __ISR(3) ButtonInterrupt(void){ | |
i = i+25; | |
if(i>100) | |
{//reset duty cycle | |
i = 0;} | |
OC1RS = i; //Cycle through duty cycle of 0%, 25%, 50%, 75%, 100% | |
IFS0bits.INT0IF = 0; // Clear Interrupt Flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <plib.h> | |
//This is here to make timing calculations easier! | |
#pragma config FPBDIV = DIV_2 | |
//r is a Rest. The value doesn't matter, it just has to be unique (not another note) | |
#define r 3000 | |
//I added another octave of notes that they didn't give us | |
//Cs = C sharp. Eb = E flat. Everything else is normal. | |
//lowest notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void __ISR(3) JacobIsCool_Int1(void){ | |
//Read in values | |
//A rising edge | |
//CW 1 to 2 | |
//CCW 4 to 3 | |
//A falling edge | |
//CCW 2 to 1 | |
//CW 3 to 4 | |
//Keep count between 0 and 15 | |
//Write to LEDs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ISR THINGY JacobIsCool(void) { | |
//Turn on all 4 lights | |
// wait a second | |
//Clear flag | |
} | |
main(){ | |
//Set LED Pins to OUTPUT | |
//Set the interrupt pin to input | |
/* Tell controller Interrupts can happen */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main(){ | |
//Set up inputs and outputs | |
//Turn on comparators | |
// Set common comparator Voltages | |
//Set up each comparator CCH CREF CPOL | |
while(1) | |
{ | |
//Write the outputs of the comparators to the output pins | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//delay for a given number of milliseconds (approximated) | |
delay(int delayTime){ | |
int i, j; | |
for(i = 0; i < delayTime; i++) | |
for(j = 0; j < 312; j++); | |
} | |
digitalWrite(int pin, bool pinState) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <FastLED.h> | |
#include <LowPower.h> | |
#include <EEPROM.h> | |
//FastLED setup | |
#define NUM_LEDS 4 | |
#define PIN 3 //Data pin for LED strip | |
CRGB leds[NUM_LEDS]; | |
//Twinkle setup |
NewerOlder