#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //turns on LED
cout << "gonna blink now;)" << '\n';
while(true)
{
sleep_ms(300);
cyw43_arch_gpio_put(0, !cyw43_arch_gpio_get(0)); //blinks LED
}
}
#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //turns on LED
rcc_init_pushbutton(); //set up button
while(true)
{
if(!gpio_get(RCC_PUSHBUTTON)) //if gpio NOT high
{
//do stuff here when button pressed
cout << "PUSHBUTTON PRESSED!" << '\n';
}
}
}
#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //led on
rcc_init_potentiometer(); //setup ADC
while(true)
{
int32_t pot_val = adc_read(); //values from 0 to +4097
cout << "raw value: " << pot_val << '\n';
sleep_ms(100);
}
}
#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //led on
Motor motors; //struct setup
MotorInit(&motors, RCC_ENA, RCC_ENB, 1000); //setup left and right
MotorsOn(&motors); //enable PWM
while(true)
{
MotorPower(&motors, 100, 100); // %motor speed
cout << "motors going forwards" << '\n';
sleep_ms(100);
}
}
#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //led on
Servo s3; //struct setup
ServoInit(&s3, 18, false, 50); //setup
ServoOn(&s3); //enable PWM
while(true)
{
ServoPosition(&s3, 50); //50% of range (forwards)
cout << "servo facing forwards" << '\n';
sleep_ms(100);
}
}
#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //led on
rcc_init_i2c(); //setup pico i2c
VL53L0X lidar; //class
rcc_init_lidar(&lidar); //setup lidar on i2c1
while(true)
{
uint16_t dist = getFastReading(&lidar);
cout << "distance: " << dist << "\n";
sleep_ms(100);
}
}
#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //led on
rcc_init_i2c(); //setup i2c
MPU6050 imu; //class
imu.begin(i2c1); //adds to i2c1
imu.calibrate(); //hold robot still
while(true)
{
imu.update_pico(); //updates data
float angvel_z = imu.getAngVelZ(); //call function to get data
cout <<" z rotation: " << angvel_z << "\n";
sleep_ms(100);
}
}
#include "rcc_stdlib.h"
using namespace std;
int main()
{
stdio_init_all();
sleep_ms(1500);
cyw43_arch_init(); //setup
cyw43_arch_gpio_put(0,1); //led on
Left_Odom left; //class
Right_Odom right; //class
while(true)
{
int left_count = left.getCount(); //current left count
int right_count = right.getCount(); //current right count
if (left_count>=100){
left.setZero(); //resets left count
}
if (right_count>=200){
right.setZero(); //resets right count
}
cout << left_count << " | " << right_count << '\n';
sleep_ms(100);
}
}