Skip to content

Instantly share code, notes, and snippets.

/*
* 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
#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
#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
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
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 */
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
}
@jakabo27
jakabo27 / PIC32JacobLibrary.c
Created September 12, 2018 23:14
A shortcut library for using the PIC32 microcontroller to make digital pin interfacing more user-friendly
//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)
{
@jakabo27
jakabo27 / FiberOptic_ClemsonPic.ino
Created July 22, 2018 15:29
The Arduino code running 4 color modes on an Arduino UNO for some WS2812B LED strip lights using the FastLED library
#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