upload setup

This commit is contained in:
Gabri6 2023-05-16 14:36:12 +02:00
parent 17ad034d5a
commit fe0c6570b7
1 changed files with 38 additions and 0 deletions

View File

@ -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:
}