Assignment to be done:
1.Group Assignment:
.Probe an input device(s)'s analog and digital signals
.Document your work on the group work page and reflect on your individual page what you learned
To be found here
What I learned from interfacing input devices to Microcontroller
There two types of input devices which are analog and digital devices. This means that when you are going to connect these devices on microcontroller first you have to know whether the device is analog or digital
sothat you will know on which pin of microcontroller will be connected as microcontroller has both digital and analog pins.
Milling process of the board
connecting input and output files and setting the X,Y,Z origins:
Then down here is the view of the board to be millled
PCB after Milling and cutting
For more about the design and fabrication process of my board, refer to here from what I have designed and produced before
The following image is of the overall of the implemented system
#include< SPI.>
#include< Wire.h>
#include< Adafruit_GFX.h>
#include< Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int AirValue = 3620; //you need to replace this value with Value_1
const int WaterValue = 1680; //you need to replace this value with Value_2
const int SensorPin = 15;
int soilMoistureValue = 0;
int soilmoisturepercent=0;
void setup() {
Serial.begin(115200); // open serial port, set the baud rate to 9600 bps
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
display.clearDisplay();
}
void loop()
{
soilMoistureValue = analogRead(SensorPin); //put Sensor insert into soil
Serial.println(soilMoistureValue);
soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
if(soilmoisturepercent > 100)
{
Serial.println("100 %");
display.setCursor(45,0); //oled display
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("Soil");
display.setCursor(20,15);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("Moisture is");
display.setCursor(30,40); //oled display
display.setTextSize(3);
display.setTextColor(WHITE);
display.println("100 %");
display.display();
delay(250);
display.clearDisplay();
}
else if(soilmoisturepercent <0)
{
Serial.println("0 %");
display.setCursor(45,0); //oled display
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("Soil");
display.setCursor(20,15);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("Moisture is ");
display.setCursor(30,40); //oled display
display.setTextSize(3);
display.setTextColor(WHITE);
display.println("0 %");
display.display();
delay(250);
display.clearDisplay();
}
else if(soilmoisturepercent >=0 && soilmoisturepercent <= 100)
{
Serial.print(soilmoisturepercent);
Serial.println("%");
display.setCursor(45,0); //oled display
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("Soil");
display.setCursor(20,15);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("Moisture is");
display.setCursor(30,40); //oled display
display.setTextSize(3);
display.setTextColor(WHITE);
display.println(soilmoisturepercent);
display.setCursor(70,40);
display.setTextSize(3);
display.println(" %");
display.display();
delay(250);
display.clearDisplay();
}
}
Problems I ecountered and how resolved2023 All Rights Reserved. Designed by Felix NYIRIGIRA