#include <Arduino_FreeRTOS.h>
#include <Servo.h>
Servo myservo;
void task1( void *pvParameters );
void task2( void *pvParameters );
int Analog;
int Value;
void setup() {
Serial.begin(9600);
myservo.attach(11);
while (!Serial) {;}
xTaskCreate(Task1, "task1", 128, 0, 2, 0 );
xTaskCreate(Task2, "task2", 128, 0, 1, 0 );
}
void loop()
{
}
void task1(void *pvParameters)
{
(void) pvParameters;
const int pinPIR = 8;
pinMode(pinPIR, INPUT);
const int pinButton = 2;
pinMode(pinButton, INPUT);
const int pinPoten = 2;
pinMode(pinPoten, INPUT);
while(;;)
{
int PottenState = digitalRead(pinPotten);
Myservo.write(0);
distance = Potten.read();
vTaskDelay(1);
}
}
void task2(void *pvParameters)
{
(void) pvParameters;
pinMode(8, OUTPUT);
for(1)
{
Value = analogRead(pir);
fixvalue = map(value, 0, 1023, 0, 300);
}
}