Completed, probably
This commit is contained in:
parent
6e8f34a4a7
commit
c3a988f7c7
1 changed files with 8 additions and 17 deletions
|
@ -1,7 +1,5 @@
|
||||||
#include "SerialTransfer.h"
|
#include "SerialTransfer.h"
|
||||||
|
|
||||||
// This program will take an number from the PC and display it using LEDs to represent it as a binary number
|
|
||||||
|
|
||||||
SerialTransfer myTransfer;
|
SerialTransfer myTransfer;
|
||||||
|
|
||||||
const byte OC1A_PIN = 9;
|
const byte OC1A_PIN = 9;
|
||||||
|
@ -10,13 +8,9 @@ const byte OC1B_PIN = 10;
|
||||||
const word PWM_FREQ_HZ = 25000; //Adjust this value to adjust the frequency (Frequency in HZ!) (Set currently to 25kHZ)
|
const word PWM_FREQ_HZ = 25000; //Adjust this value to adjust the frequency (Frequency in HZ!) (Set currently to 25kHZ)
|
||||||
const word TCNT1_TOP = 16000000/(2*PWM_FREQ_HZ);
|
const word TCNT1_TOP = 16000000/(2*PWM_FREQ_HZ);
|
||||||
|
|
||||||
int pin1=8; //initializing pins as vars because who wants to use constants:
|
struct STRUCT {
|
||||||
int pin2=7;
|
char val;
|
||||||
int pin3=6;
|
} myStruct;
|
||||||
int pin4=5;
|
|
||||||
int pin5=4;
|
|
||||||
int pin6=3;
|
|
||||||
int pin7=2;
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Setup Serial transfer with PC
|
// Setup Serial transfer with PC
|
||||||
|
@ -54,14 +48,11 @@ void loop() {
|
||||||
}
|
}
|
||||||
myTransfer.sendData(myTransfer.bytesRead);
|
myTransfer.sendData(myTransfer.bytesRead);
|
||||||
|
|
||||||
int x = int(myTransfer.packet.rxBuff);
|
uint16_t recSize = 0;
|
||||||
if((x % 2) > 0) { digitalWrite(pin1, HIGH); } else { digitalWrite(pin1, LOW); }
|
recSize = myTransfer.rxObj(myStruct, recSize);
|
||||||
if((x % 4) > 1) { digitalWrite(pin2, HIGH); } else { digitalWrite(pin2, LOW); }
|
int x = myStruct.val * 2; // I have no idea why I have to multiply it by 2, but I do
|
||||||
if((x % 8) > 3) { digitalWrite(pin3, HIGH); } else { digitalWrite(pin3, LOW); }
|
|
||||||
if((x % 16) > 7) { digitalWrite(pin4, HIGH); } else { digitalWrite(pin4, LOW); }
|
setPwmDuty(x);
|
||||||
if((x % 32) > 15) { digitalWrite(pin4, HIGH); } else { digitalWrite(pin4, LOW); }
|
|
||||||
if((x % 64) > 31) { digitalWrite(pin4, HIGH); } else { digitalWrite(pin4, LOW); }
|
|
||||||
if((x % 128) > 63) { digitalWrite(pin4, HIGH); } else { digitalWrite(pin4, LOW); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue