I recently picked up the “Starter Kit for Seeed Studio XAIO” and I am working my way through the examples with a ESP32C3. The first 3 example programs seem to have a number of errors and I am wondering if I am missing something. The first program (page 30) looks like this:
/*
* Button controlling external LED of XIAO ESP32C3
*/
const int buttonPin = 1; // The pin number of the button
int buttonState = 0; // Variable for reading the button status
int led = D10; // Pin number of the LED
void setup() {
// Initialize the LED pin as an output:
pinMode(led, OUTPUT);
// Initialize the button pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// Read the state of the button:
buttonState = digitalRead(buttonPin);
// Check if the button is pressed. If it is, the button state is HIGH
if (buttonState == HIGH) {
// Turn the LED on:
digitalWrite(led, HIGH);
}
else {
// Turn the LED off:
digitalWrite(led, LOW);
}
}
setting buttonPin = 1 does nothing but buttonPin = D1 works. Additionally, the light stays on unless the button is pushed (instead of turning on when pushed as the code states).
Same with the Buzzer program on page 35:
int pinBuzzer = 3; // Define the buzzer on pin 3, if you're using XIAO RP2040/XIAO ESP32, change 3 to A3
A3 returns an error that it is not defined in scope, 3 does not work (as stated in the book), but D3 works. As with the previous example, the on board button is reporting HIGH when not pressed, so the next example of using the button to control the buzzer, leaves the buzzer on unless the button is pressed.
Am I doing something wrong? Is the book just out of date?
Also just tried the potentiometer example and while it works, when the knob is turned all the way clockwise, the values go down. When turned all the way counter clockwise, the values go up. Am I crazy or is this not the opposite of what should happen?
https://mjrovai.github.io/XIAO_Big_Power_Small_Board-ebook/
Does anyone have a pdf version? Thanks for letting me know I didnt know this book existed
it is verry complex and confusing, but basicly the pin number D1 is just a human readable form of the pin name… like for example Builtin_LED… it is not actually a number but is acting as a variable… a define to be correct, this define is setup when the board is selected… this is why you have to use the XIAO Board Support File/Denfinition and not something like ESP32vroom or whathaveyou
Also some rgp led are common cathode and some are common annode… depending on which one, it will either be brought high or low to turn on… this is confusing because you assume you bring the pin high to supply power to the led to turn it on… but in the other wireing type, you actually bring the pin to ground to turn it on… also i think the user switch on the XIAO Expansion Board is also wired this way… the switch opperated opposite … the switch actually brings the line low… I am not exactly sure why it is this way… but i am assuming it is easier on the hardware to sink ground than source current.
Look at Lesson 2 starting on page 21
The potentiometer is a variable resister…
it has three pins… The grove connector has 4 pins… one is NC Not Connected to anything
The middle pin is connected to the wiper… which is the pin that moves inside the case
the pins on either side are stationary… the closer you put the wiper to one pin or the other, the more the signal voltage will be close to the supply voltage at that pin… so if you move the wiper all the way to the ground side, the signal will go to ground, the more you move the wiper toward the VCC the higher the voltage will be… If you need to reverse the action, you could change the wiring or reverse the effect in code.
1 Like
There is a link for " * Download the eBook PDF Version" on the page. That’s where I got it from.
1 Like
Thanks for the info on the rotary. That makes sense. I have a musician’s perspective that turning it up (clockwise), means more volume (bigger numbers). ![:slight_smile: :slight_smile:](https://forum.seeedstudio.com/images/emoji/twitter/slight_smile.png?v=12)
1 Like