顯示具有 Arduino 標籤的文章。 顯示所有文章
顯示具有 Arduino 標籤的文章。 顯示所有文章

2022/06/12

Arduino: Hello World for WeMos D1 WIFI UNO

 Here are the steps for the WeMos D1 WIFI UNO:


1.  Select File -> Preferences




2.  Settings -> Additional Boards Manager URLs: 

http://arduino.esp8266.com/stable/package_esp8266com_index.json

 


3. Tools -> Board: "Arduino Uno" -> Boards Manager

4. Enter WeMos and select Install for ESP8266.



5. Select "LOLIN(WeMos) D1 R1

 

6. Select COM port


7. Write the simple code below and select the arrow to download

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Hello world, Arduino!");
}

void loop() {
  // put your main code here, to run repeatedly:
  
}
 


8. Select the Serial Monitor


9. You may see strange characters after you press the reset button.

 


10. Move the print line function into the loop. The strange characters only happen after pressing the reset button. So you may ignore them.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Hello world, Arduino!");  
  delay(1000);
}
 

Related information: 

2019/01/24

Arduino: Button Detection with LED Control

1. Connect the button circuit according to the official Button page.

2. Connect the LED circuit to pin 13 according to the official Blink page or the circuit in the "Hello World with blinking LED" example.




3. Connect your Arduino to a computer via a USB cable.

4. Select Example -> 02.Digital -> Button.

5. Download the code. The LED should be turned on by Arduino when the button is pressed.


Related Information:

Arduino: Hello World! (StudyEECC)

2019/01/19

Arduino: Hello World with blinking LED

This tutorial shows how to display "Hello World" by Arduino and blink the built-in LED on the Arduino board or blink an external LED via wire connections.

Before working on this example, make sure you understand the pure Hello World example for Arduino.

Part A. Arduino built-in LED

1. Select File->Examples->01.Basics->Blink

2.  Modify the code as:

int count=0;
void setup() {
  Serial.begin(9600);
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  Serial.println("Hello, world!");
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  Serial.println(count);
  delay(1000);                       // wait for a second
  count++;
}

3. Download the code and open the serial monitor

Result:


You should also see the LED on the Arduino board blinking.

Part B. External LED

1. Follow the figure shown in the official page for circuit connections from pin 13 to ground (GND) via an LED. Connect the longer leg / pin of the LED (called the anode) to the pin 13 with 5V power. The resistor value should be between 220 ohm and 1k ohm, but for me 2k ohm also works.

2. Modify the code as below:

int count=0;
int LED13=13; // For the external LED at pin 13
void setup() {
  Serial.begin(9600);
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(LED13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED13, HIGH);   // turn on the external LED at pin 13
  Serial.println("Hello, world!");
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  digitalWrite(LED13, LOW);         // turn off the external LED at pin 13
  Serial.println(count);
  delay(1000);                       // wait for a second
  count++;
}

Result:


Reference:

Arduino: Hello, World! (StudyEECC)

Arduino: Hello, World!

This is the first tutorial with Arduino. "Hello World" is usually the very first program to learn a new programming language with a simple command that prints out the "Hello, World!" message.

2. Connect the Arduino board to your computer via a USB cable. Note that in this case the power of the Arduino board is supplied by the 5V USB cable and it is not required to connect to an external DC adapter.

3. In the Arduino IDE window, type the following code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Hello world, Arduino!");
}

void loop() {
  // put your main code here, to run repeatedly:
}



3. Select Tools -> your Arduino board such as the popular Arduino Uno.

4. Select Tools -> COM port.

5. Select the upload button and save the project.

6. Select Tools -> Serial monitor.

7. You should see the result if the serial monitor is properly set.

Reference:

Hello World
Arduino: Hello World with blinking LED (StudyEECC)