upload setup
This commit is contained in:
parent
17ad034d5a
commit
fe0c6570b7
|
|
@ -0,0 +1,38 @@
|
|||
#include <Servo.h>
|
||||
|
||||
#define SAMPLESIZE 100;
|
||||
|
||||
int Sensor_1;
|
||||
int samples[SAMPLESIZE];
|
||||
int timer;
|
||||
int oldTimer;
|
||||
int delayBetweenOutput = 100;
|
||||
int servoPin = 3;
|
||||
|
||||
Servo balanceScale
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
pinMode(servoPin,OUTPUT);
|
||||
balanceScale.attach(3);
|
||||
//set timer2 interrupt at 2kHz
|
||||
TCCR2A = 0;// set entire TCCR2A register to 0
|
||||
TCCR2B = 0;// same for TCCR2B
|
||||
TCNT2 = 0;//initialize counter value to 0
|
||||
// set compare match register for 1khz increments
|
||||
OCR2A = 250;// = (16*10^6) / (1000*64) - 1 (must be <256)
|
||||
// turn on CTC mode
|
||||
TCCR2A |= (1 << WGM21);
|
||||
// Set CS21 and CS20 bits for 64 prescaler
|
||||
TCCR2B |= (1 << CS21) | (1 << CS20);
|
||||
// enable timer compare interrupt
|
||||
TIMSK2 |= (1 << OCIE2A);
|
||||
sei(); // Enable interrupts
|
||||
timer = millis()
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue