Skip to content

Commit 59df0df

Browse files
committed
Removed unneeded Timer2 freq change code, as only one line was needed for the job.
1 parent 2a87d52 commit 59df0df

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

ldc500/ldc500.ino

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Main Functions:
55
* ENABLE/DISABLE Laser -> Pin 13 + LED
6-
* SET Laser Current -> Pin 11
6+
* SET Laser Current -> Pin 11 (Changed to 31 kHz
77
* GET Laser Current -> A0
88
LDC500 -> k=50mA/V
99
@@ -33,30 +33,13 @@ const int dht22Pin = 8;
3333
String inputString = ""; // a string to hold incoming data
3434
boolean stringComplete = false; // whether the string is complete
3535

36-
// Change PWM Frequency for Timer2.
37-
// Copied the relevant part from here:
38-
// http://playground.arduino.cc/Code/PwmFrequency
39-
void setPwmFrequency(int pin, int divisor) {
40-
byte mode;
41-
if(pin == 3 || pin == 11) {
42-
switch(divisor) {
43-
case 1: mode = 0x01; break;
44-
case 8: mode = 0x02; break;
45-
case 32: mode = 0x03; break;
46-
case 64: mode = 0x04; break;
47-
case 128: mode = 0x05; break;
48-
case 256: mode = 0x06; break;
49-
case 1024: mode = 0x7; break;
50-
default: return;
51-
}
52-
TCCR2B = TCCR2B & 0b11111000 | mode;
53-
}
54-
}
55-
5636
void setup() {
5737
pinMode(laserREM, OUTPUT);
5838
pinMode(laserMod, OUTPUT);
59-
setPwmFrequency(laserMod, 1);
39+
// Change PWM Frequency for Timer2.
40+
// Copied the relevant part from here:
41+
// http://playground.arduino.cc/Code/PwmFrequency
42+
TCCR2B = TCCR2B & 0b11111000 | 0x01;
6043
Serial.begin(115200);
6144
// reserve 200 bytes for the inputString:
6245
inputString.reserve(200);

0 commit comments

Comments
 (0)