Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pushcode #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
31 changes: 31 additions & 0 deletions exercise.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include<Arduino.h>
#define BUTTON_PIN 26
#define LED_PIN 18


int led_state = LOW;
int button_state;

void setup() {

Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
button_state = digitalRead(BUTTON_PIN);
}

void loop() {
button_state = digitalRead(BUTTON_PIN);
delay(100);
if (button_state == LOW) {
Serial.println("The button is pressed");
// toggle state of LED
digitalWrite(LED_PIN, HIGH);
delay(5000);
digitalWrite(LED_PIN, LOW);
delay(1000);
}else{
digitalWrite(LED_PIN, LOW);
delay(1000);
}