banner image
Sedang Dalam Perbaikan

Mini Oscilloscope with LCD Nokia5110 Module

Module yang dibutuhkan :

1x Module LCD Nokia 5110/3310 for Arduino
1x Potensiometer / trimpot / VR 10K
1x Arduino Uno/Nano/Pro mini atau type lain
Probe (optional) bisa pakai kabel jumper atau probe multitester
beberapa pcs kabel jumper dupont male to female
Breadboard (optional)




Library yang dibutuhkan :

#include <SPI.h> // Sudah bawaan Arduino IDE tidak perlu download lagi
#include <Adafruit_GFX.h> //Optional (tidak dibituhkan pada sketch kali ini)
#include <Adafruit_PCD8544.h> //Optional (tidak dibituhkan pada sketch kali ini)

Wiring :

LCD Nokia5110 to Arduino
-RST     --> D3
-CE / CS --> D4
-DC        --> D5
-Din        --> D6
-Clk / Sck --> D7
-Vcc        --> pin 3.3V Arduino
-BL          --> pin 5V Arduino
-Gnd         --> pin GND Arduino

Potensiometer to Arduino
-Pin 1 (pinggir kanan)     --> pin GND Arduino
-Pin 2 (tengah)    --> pin A1 Arduino
-Pin 1 (pinggir kiri)    --> pin 5V Arduino
 //Potensiometer digunakan untuk setting update kecepatan/delay pembacaan Signal

Probe to Arduino
-Probe Merah (+)     --> pin A0 Arduino
-Probe Hitam (-)     --> pin GND Arduino
 

Sourche Code :



#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <SPI.h>

#define DISPLAY_WIDTH 84
#define DISPLAY_HEIGHT 48
#define ARDUINO_PRECISION 1023.0
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

//Analog Pins
int channelAI = A0; // probe

//disabled it I don't have it connected
#define DELAY_POTENTIMETER
#ifdef DELAY_POTENTIMETER
int delayAI = A1; // delay potentiometer on Analog A1
#endif

float delayVariable = 0;
float scale = 0;
int xCounter = 0;
int yPosition = 0;
int readings[DISPLAY_WIDTH+1];
int counter = 0;

unsigned long drawtime = 0;
unsigned long lastdraw = 0;
int frames = 0;

void setup(void)
{
display.begin();
display.setContrast(60);
display.clearDisplay();
}

void loop()
{
#ifdef DELAY_POTENTIMETER
delayVariable = analogRead(delayAI);
delayVariable = (delayVariable/100);
#endif
scale = (float)(DISPLAY_HEIGHT-1)/ARDUINO_PRECISION;

//record readings
for(xCounter = 0; xCounter <= DISPLAY_WIDTH; xCounter++)
{
yPosition = analogRead(channelAI);
readings[xCounter] = (yPosition*scale);
#ifdef DELAY_POTENTIMETER
delay (delayVariable);
#endif
}

display.clearDisplay();

//Draw Voltage Ref Lines
display.drawLine( 10, 0, 10, DISPLAY_HEIGHT-1, BLACK);
display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale), BLACK);
display.drawLine( 0, (DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale), BLACK);
display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale), BLACK);
display.drawLine( 0, (DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale), BLACK);
//display.drawLine( 5, (DISPLAY_HEIGHT-1)-(.84 *ARDUINO_PRECISION * scale), 10, (DISPLAY_HEIGHT-1)-(.84 *ARDUINO_PRECISION * scale), BLACK);

//Draw Voltage Ref Numbers
display.setCursor(0,((DISPLAY_HEIGHT-1)-(.2 *ARDUINO_PRECISION * scale))-3);
display.print((int)(5.0*0.2));
display.setCursor(0,((DISPLAY_HEIGHT-1)-(.4 *ARDUINO_PRECISION * scale))-3);
display.print((int)(5.0*0.4));
display.setCursor(0,((DISPLAY_HEIGHT-1)-(.6 *ARDUINO_PRECISION * scale))-3);
display.print((int)(5.0*0.6));
display.setCursor(0,((DISPLAY_HEIGHT-1)-(.8 *ARDUINO_PRECISION * scale))-3);
display.print((int)(5.0*0.8));

for(xCounter = 0; xCounter <= DISPLAY_WIDTH; xCounter++)
{
display.drawPixel(xCounter, (DISPLAY_HEIGHT-1)-readings[xCounter], BLACK);
if(xCounter>1){
display.drawLine(xCounter-1, (DISPLAY_HEIGHT-1)-readings[xCounter-1], xCounter, (DISPLAY_HEIGHT-1)-readings[xCounter], BLACK);
}
}
//Draw FPS
display.setCursor((DISPLAY_WIDTH-1)-11,0);
display.print(frames);

//Draw Voltage
display.setCursor(((DISPLAY_WIDTH-1)/2),0);
display.print(analogRead(channelAI)/ARDUINO_PRECISION*5.0);

display.display();

//Calculate FPS
drawtime = micros();
frames=1000000/*a second*//(drawtime-lastdraw);
lastdraw = drawtime;
}
Mini Oscilloscope with LCD Nokia5110 Module Mini Oscilloscope with LCD Nokia5110 Module Reviewed by MCH on September 19, 2016 Rating: 5

No comments:

Powered by Blogger.