Skip to content

Commit

Permalink
Fixed code snippets to work out of the box
Browse files Browse the repository at this point in the history
  • Loading branch information
tguyenn committed Sep 17, 2024
1 parent 2183e46 commit 17c99f6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ Control Pins: Connect the control pins (e.g., IN1, IN2, ENA) on the motor contro

The following is an example of configuring and running the motor in software:
```cpp
#include "sdkconfig.h"
#ifndef CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#error "Must only be compiled when using Bluepad32 Arduino platform"
#endif // !CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#include <Arduino.h>

#define IN1 27 // Control pin 1
#define IN2 26 // Control pin 2
#define ENA 25 // PWM pin
Expand Down Expand Up @@ -99,7 +105,13 @@ If you're not sure which ESP32 pins are PWM capable, then check out the diagram
In this competition, we will be using the Arduino servo library to control the servos. The following is an example of how to configure the servo:

```cpp
#include <Servo.h>
#include "sdkconfig.h"
#ifndef CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#error "Must only be compiled when using Bluepad32 Arduino platform"
#endif // !CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#include <Arduino.h>

#include <ESP32Servo.h>

Servo myservo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,31 @@ If you want more details on how the color sensor works, check out [this link!](h
For this tutorial, we’re only going to be reading the RGB sensor values from the TCS34725. Make sure that your pins are correctly connected or otherwise you won’t receive the data!

```cpp
//Color Sensor headers
#include "sdkconfig.h"
#ifndef CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#error "Must only be compiled when using Bluepad32 Arduino platform"
#endif // !CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#include <Arduino.h>


#include <Wire.h>
#include <Arduino APDS9960.h>
#include <Arduino_APDS9960.h>
#include <bits/stdc++.h>
//Color sensor definitions
#define APDS9960 INT 2
#define 120 SDA 21
#define 12C SCL 22
#define I2C FREQ 100000
//Color Sensor unit & 12C unit
Twowire I2C_0 = TwoWire(0);
APDS9960 apds = APDS9960(12C_0, APDS9960_INT);

#define APDS9960_INT 2
#define I2C_SDA 21
#define I2C_SCL 22
#define I2C_FREQ 100000

TwoWire I2C_0 = TwoWire(0);
APDS9960 apds = APDS9960(I2C_0, APDS9960_INT);

void setup() {
//Sets up I2C protocol
//sets up I2C protocol
I2C_0.begin(I2C_SDA, I2C_SCL, I2C_FREQ);
// Set up color sensor
apds.setInterruptPin (APDS9960_INT);

//sets up color sensor
apds.setInterruptPin(APDS9960_INT);
apds.begin();
Serial.begin(115200);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ If you're not sure which ESP32 pins are ADC (Analog to Digital Converter) capabl
The following program will allow you to read values from the IR sensor in a loop. After you build and flash the program, you should see the values in your terminal output change as you move it towards and away from an object.

```cpp
#include "sdkconfig.h"
#ifndef CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#error "Must only be compiled when using Bluepad32 Arduino platform"
#endif // !CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#include <Arduino.h>

#include <ESP32SharpIR.h>

void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ The following program will allow you to continuously read a general position val
different sensors.

```cpp
#include "sdkconfig.h"
#ifndef CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#error "Must only be compiled when using Bluepad32 Arduino platform"
#endif // !CONFIG_BLUEPAD32_PLATFORM_ARDUINO
#include <Arduino.h>

#include <QTRSensors.h>

QTRSensors qtr;

void setup {
void setup() {
// set up Serial Communication and sensor pins
Serial.begin(115200);
qtr.setTypeAnalog(); // or setTypeAnalog()
Expand Down

0 comments on commit 17c99f6

Please sign in to comment.