Video
I had to change the Arduino code because the first code doesn’t control the LED but instead it turn on ad off.
Here is the new Arduino code.
//Jilbert Bennett - Semester 2 Assignment 2 Ex.1 //Controlling the high LED with the MOSFET
const int led_pin = 14;
void setup() {
Serial.begin(9600); pinMode(led_pin, OUTPUT);
}
void loop() {
for (int i = 0; i<= 255; i = i + 1){ analogWrite(led_pin, i); delay(15);
}
for (int i = 255; i>= 0; i = i - 1){ analogWrite(led_pin, i); delay(15); } }
tumblr
A High LED in a circuit with a transistor on a NodeMCU.
Arduino Code:
//Jilbert_Bennett - Semester 2 Assignment 2 Ex.1
int Led_pin = 14;
void setup() { pinMode (Led_pin,OUTPUT);
}
void loop() { digitalWrite(Led_pin,LOW); delay(4000); digitalWrite(Led_pin,HIGH); delay(4000); }
2 notes
·
View notes
Photo




On this Assignment I teamed up with one of my classmates and I’m the Person A. My task is to send the information from one NodeMCU to an other NodeMCU. We use a distant sensor for the assignment.
Arduino Code:
//Jilbert Semester 2 Assignment 3 //NodeMCU Pin D1 - Trigger Pin D2 - Echo
#include <ESP8266WiFi.h> #include “ThingSpeak.h” #include “Secret.h”
//WiFi Credentials char ssid[] = “KABK-Students”; char pass[] = “kabk@air”;
long myChannel_ID = 779874; char myReadAPIKey[] = “GY30830EPY6V4LQ3”;
int FieldNumber_data = 1; int data_download = 0; int wait = 15000;
WiFiClient client;
//ThingSpeak Credentials //unsigned long myChannelNumber = 779874; //char myWriteAPIKey[] = “FXCZ9F80OCYFR234”;
int wait2 = 1000;
void setup() {
Serial.begin(9600); WiFi.mode (WIFI_STA); ThingSpeak.begin(client);
}
void loop() {
if (WiFi.status() != WL_CONNECTED){ Serial.println(“try to connect”); while (WiFi.status() != WL_CONNECTED){ WiFi.begin(ssid, pass); Serial.println(“…”); delay(5000); }
Serial.println(“connected”);
}
data_download = ThingSpeak.readLongField (myChannel_ID, FieldNumber_data, myReadAPIKey); int statusCode = ThingSpeak.getLastReadStatus(); if (statusCode ==200){ Serial.println(“in cm”); Serial.println(data_download);
}
delay(wait2);
}
1 note
·
View note
Photo

On this Assignment I teamed up with one of my classmates and I’m the Person A. My task is to send the information from one NodeMCU to an other NodeMCU. We use a distant sensor for the assignment.
Arduino Code:
//Jilbert Semester 2 Assignment 3 //NodeMCU Pin D1 - Trigger Pin D2 - Echo
#include <ESP8266WiFi.h> #include "ThingSpeak.h" #include "Secret.h"
//WiFi Credentials char ssid[] = "KABK-Students"; char pass[] = "kabk@air";
long myChannel_ID = 779874; char myReadAPIKey[] = "GY30830EPY6V4LQ3";
int FieldNumber_data = 1; int data_download = 0; int wait = 15000;
WiFiClient client;
//ThingSpeak Credentials //unsigned long myChannelNumber = 779874; //char myWriteAPIKey[] = "FXCZ9F80OCYFR234";
int wait2 = 1000;
void setup() {
Serial.begin(9600); WiFi.mode (WIFI_STA); ThingSpeak.begin(client);
}
void loop() {
if (WiFi.status() != WL_CONNECTED){ Serial.println("try to connect"); while (WiFi.status() != WL_CONNECTED){ WiFi.begin(ssid, pass); Serial.println("..."); delay(5000); }
Serial.println("connected");
}
data_download = ThingSpeak.readLongField (myChannel_ID, FieldNumber_data, myReadAPIKey); int statusCode = ThingSpeak.getLastReadStatus(); if (statusCode ==200){ Serial.println("in cm"); Serial.println(data_download);
}
delay(wait2);
}
1 note
·
View note
Text
Int and Long
Int is a data type that is the most commonly used data type which holds an integer value in it. A value that an int variable can hold is not too short and not too long.
Long is the data type that has the largest range and width as compared to byte, short, and int types.
int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)
long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)
0 notes
Video



tumblr
A DC Motor with a relay circuited on a NodeMCU. The motor have to turn on every 4 seconds.
Arduino Code:
//Jilbert_Bennett - Semester 2 Assignment 2 Ex.2
int Motor_pin = 14;
void setup() { pinMode(Motor_pin,OUTPUT);
}
void loop() { digitalWrite(Motor_pin,LOW); delay(4000); digitalWrite(Motor_pin,HIGH); delay(4000);
}
1 note
·
View note
Video
tumblr
A DC Motor with a relay circuited on a NodeMCU. The motor have to turn on every 4 seconds.
Arduino Code:
//Jilbert_Bennett - Semester 2 Assignment 2 Ex.2
int Motor_pin = 14;
void setup() { pinMode(Motor_pin,OUTPUT);
}
void loop() { digitalWrite(Motor_pin,LOW); delay(4000); digitalWrite(Motor_pin,HIGH); delay(4000);
}
1 note
·
View note
Video


tumblr
A High LED in a circuit with a transistor on a NodeMCU.
Arduino Code:
//Jilbert_Bennett - Semester 2 Assignment 2 Ex.1
int Led_pin = 14;
void setup() { pinMode (Led_pin,OUTPUT);
}
void loop() { digitalWrite(Led_pin,LOW); delay(4000); digitalWrite(Led_pin,HIGH); delay(4000); }
2 notes
·
View notes
Video
tumblr
A High LED in a circuit with a transistor on a NodeMCU.
Arduino Code:
//Jilbert_Bennett - Semester 2 Assignment 2 Ex.1
int Led_pin = 14;
void setup() { pinMode (Led_pin,OUTPUT);
}
void loop() { digitalWrite(Led_pin,LOW); delay(4000); digitalWrite(Led_pin,HIGH); delay(4000); }
2 notes
·
View notes
Video




tumblr
On this assignment I use a distant sensoron a NodeMCU and it record and show the distance via thinspeak.com.
Arduino Code:
//Jilbert_Bennett - Semester 2 Assignment 3 //NodeMCU Pin D1 - Trigger Pin D2 - Echo
#define TRIGGER 5 #define ECHO 4
#include <ESP8266WiFi.h> #include “ThingSpeak.h”
//WiFi Credentials char ssid[] = “***************”; //Censored the code for private reason char pass[] = “****************”; //Censored the code for private reason
WiFiClient client;
//ThingSpeak Credentials unsigned long myChannelNumber = 7*****4; //Censored the code for private reason char myWriteAPIKey[] = “F****************4”; //Censored the code for private reason
int wait = 5000;
void setup() {
Serial.begin(9600); WiFi.begin(ssid, pass); while(WiFi.status() != WL_CONNECTED){ delay(500); }
ThingSpeak.begin(client);
pinMode(TRIGGER, OUTPUT); pinMode(ECHO, INPUT); pinMode(BUILTIN_LED, OUTPUT);
}
void loop() {
long duration, distance; digitalWrite(TRIGGER, LOW); delayMicroseconds(2);
digitalWrite(TRIGGER, HIGH); delayMicroseconds(10);
digitalWrite(TRIGGER, LOW); duration = pulseIn(ECHO, HIGH); distance = (duration/2) / 29.1;
Serial.print(“Centimeter:”); Serial.println(distance); delay(1000);
ThingSpeak.setField(1, distance);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
delay(wait);
}
1 note
·
View note
Video
tumblr
On this assignment I use a distant sensoron a NodeMCU and it record and show the distance via thinspeak.com.
Arduino Code:
//Jilbert_Bennett - Semester 2 Assignment 3 //NodeMCU Pin D1 - Trigger Pin D2 - Echo
#define TRIGGER 5 #define ECHO 4
#include <ESP8266WiFi.h> #include "ThingSpeak.h"
//WiFi Credentials char ssid[] = "***************"; //Censored the code for private reason char pass[] = "****************"; //Censored the code for private reason
WiFiClient client;
//ThingSpeak Credentials unsigned long myChannelNumber = 7*****4; //Censored the code for private reason char myWriteAPIKey[] = "F****************4"; //Censored the code for private reason
int wait = 5000;
void setup() {
Serial.begin(9600); WiFi.begin(ssid, pass); while(WiFi.status() != WL_CONNECTED){ delay(500); }
ThingSpeak.begin(client);
pinMode(TRIGGER, OUTPUT); pinMode(ECHO, INPUT); pinMode(BUILTIN_LED, OUTPUT);
}
void loop() {
long duration, distance; digitalWrite(TRIGGER, LOW); delayMicroseconds(2);
digitalWrite(TRIGGER, HIGH); delayMicroseconds(10);
digitalWrite(TRIGGER, LOW); duration = pulseIn(ECHO, HIGH); distance = (duration/2) / 29.1;
Serial.print("Centimeter:"); Serial.println(distance); delay(1000);
ThingSpeak.setField(1, distance);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
delay(wait);
}
1 note
·
View note
Video
tumblr
This circuit is about 6 LED (each LED has 220 Ohm) in a dice formation and it is connect to a Arduino and a normally open switch that when pressed generate a random number and turn on the specific LED indicating the number of the dice.
Arduino code:
//Code by Gus @ arduinomylifeup.com
//Pin to to turn dice on & off int button = 13; //LED for DICE int bottomLeft = 5; int middleLeft = 6; int upperLeft = 7; int middle = 8; int bottomRight = 2; int middleRight = 3; int upperRight = 4;
int buttonstate = 0; long randNumber;
//Initial setup void setup(){ pinMode(bottomLeft, OUTPUT); pinMode(middleLeft, OUTPUT); pinMode(upperLeft, OUTPUT); pinMode(middle, OUTPUT); pinMode(bottomRight, OUTPUT); pinMode(middleRight, OUTPUT); pinMode(upperRight, OUTPUT);
pinMode(button, INPUT); Serial.begin(9600); randomSeed(analogRead(0)); }
void loop(){ //Read our button if high then run dice if (digitalRead(button) == LOW && buttonstate == 0){ buttonstate = 1; randNumber = random(1, 7); delay(50); Serial.println("FEELING LUCKY?: "); Serial.println(randNumber);
if (randNumber == 6){ six(); } if (randNumber == 5){ five(); } if (randNumber == 4){ four(); } if (randNumber == 3){ three(); } if (randNumber == 2){ two(); } if (randNumber == 1){ one(); } delay(2000); clearAll(); buttonstate = 0; delay(1000); } }
//Create a function for each of our "sides" of the die void six() { digitalWrite(bottomLeft, HIGH); digitalWrite(middleLeft, HIGH); digitalWrite(upperLeft, HIGH); digitalWrite(bottomRight, HIGH); digitalWrite(middleRight, HIGH); digitalWrite(upperRight, HIGH); }
void five() { digitalWrite(upperLeft, HIGH); digitalWrite(bottomLeft, HIGH); digitalWrite(middle, HIGH); digitalWrite(upperRight, HIGH); digitalWrite(bottomRight, HIGH); }
void four() { digitalWrite(upperLeft, HIGH); digitalWrite(bottomLeft, HIGH); digitalWrite(upperRight, HIGH); digitalWrite(bottomRight, HIGH); }
void three() { digitalWrite(upperLeft, HIGH); digitalWrite(middle, HIGH); digitalWrite(bottomRight, HIGH); }
void two() { digitalWrite(bottomRight, HIGH); digitalWrite(upperLeft, HIGH); }
void one(){ digitalWrite(middle, HIGH); }
void clearAll(){ digitalWrite(bottomLeft, LOW); digitalWrite(middleLeft, LOW); digitalWrite(upperLeft, LOW); digitalWrite(middle,LOW); digitalWrite(bottomRight, LOW); digitalWrite(middleRight, LOW); digitalWrite(upperRight, LOW);
0 notes
Video
Using a potentiometer, you can control 2 LED (both with 220 Ohm resistors) connect to the arduino.
Arduino Code:
int led1_pin = 3; int led2_pin = 5; //led2 pin
int pot_pin = A0; // define the pin of the potentiometer int pot_valuel = 0; // variable to save pot values
void setup() { // put your setup code here, to run once:
pinMode(pot_pin, INPUT); pinMode(led1_pin, OUTPUT); pinMode(led2_pin, OUTPUT);
Serial.begin(9600); }
void loop() { // put your main code here, to run repeatedly:
pot_valuel = analogRead (pot_pin);
pot_valuel = map(pot_valuel, 0, 1023, 0, 255);
analogWrite (led1_pin, pot_valuel); analogWrite (led2_pin, pot_valuel);
}
tumblr
Exercise 4
1 note
·
View note
Video
A circuit that consist of a normally open switch that when pressed, it turn on the LED. The circuit also has a 220 ohm and a 9V battery.

tumblr
Exercise 3
1 note
·
View note
Photo
Using the 9V battery with a 220 omh resistor to power up a LED


Exercise 2
1 note
·
View note