Semua Tentang Belajar Teknologi Digital Dalam Kehidupan Sehari - Hari

Kamis, 02 Juli 2020

The Coolest Way To Visualize VU Meter From Arduino to Microsoft Excel



On this tutorial i will try to show you how cool is python if combined with arduino, as i've already wrote on previous blogs Here dan Here . Sorry since i was writing only in Bahasa so please use google translate for your convenience and now i would like to write in english and i hope you'll understand.

First prepare some components from this schematic for amplifier part, the purpose is to create audio signal gain (from condenser mic) which is too weak for arduino's ADC to read from. 

Since we only want to read the signal's voltage so we can skip loud speaker part, but if you want to hear some poor noisy sound then it is up to you. Pin no 5 of LM386 can directly feed into any arduino ADC pin and the power supply can directly connected to 5 volt on arduino. The Script is quite simple as i only copy and paste from arduino's ADC example scripts collection.


int analogPin = A0; // Any ADC Pin on ardiuno
                    
int val = 0;  // variable to store the value read

void setup() {
  Serial.begin(9600);           //  setup serial
}

void loop() {
  val = analogRead(analogPin);  // read the input pin
  Serial.println(val);          // send value to serial
  delay(100);   // 100 ms delay is the best, try other number
}
That is one simple scripts, i only use hardware serial directly connecting to USB COM port then the python will do the rest. Xlwings library is a simple tools to write and read directly to any excel 'cell' so then the graph chart on excel can becoming "alive" in real time if the data is changed rapidly. 


import serial #serial library
import xlwings as xw #excel library

wb = xw.Book('Audio.xlsx') #file name, change accordingly
sht = wb.sheets['data'] #sheets name, change it depend on your excel
row = 1

serialPort = serial.Serial(port = "COM4", baudrate=9600,   #baudrate
                           bytesize=8, timeout=2, 
                           stopbits=serial.STOPBITS_ONE)

serialString = ""   

while(1):
    if(serialPort.in_waiting > 0): #read if any serial data is coming
        serialString = serialPort.readline()
        data=serialString.decode('utf-8')     
        print(data) 
        if row == 51: #reset the row
          row=2 
        else: 
          row=row+1
        audio='A'+str(row) #new cell
        sht.range(audio).value= float(data) #write cell

The scripts read the integer value from ADC readout which is sent by arduino, then write it rapidly on cell A2 until A51 in excel file. The graph will be "dancing" according to the sound wave traveling through the condenser microphone.



As microsoft excel is easy to use or to customize then you can create any chart or graph you like and can be use as simple visualization as long as the data speed is not very fast, eg: Heart Beat or ECG.





 I hope you understand and happy Visualizing your favorite music on Excel


Naya Marie Rivera , naya rivera, glee, @nayarivera, missing
Share:

0 komentar:

Posting Komentar

Kontak Penulis



12179018.png (60Ɨ60)
+628155737755

Mail : ahocool@gmail.com

Site View

Categories

555 (8) 7 segmen (3) adc (4) amplifier (2) analog (19) android (14) antares (11) arduino (27) artikel (11) attiny (3) attiny2313 (19) audio (5) baterai (5) blog (1) bluetooth (1) chatgpt (2) cmos (2) crypto (2) dasar (46) digital (11) dimmer (5) display (3) esp8266 (26) euro2020 (13) gcc (1) gsm (1) iklan (1) infrared (2) Input Output (3) iot (75) jam (7) jualan (12) kereta api (1) keyboard (1) keypad (3) kios pulsa (2) kit (6) komponen (17) komputer (3) komunikasi (1) kontrol (8) lain-lain (8) lcd (2) led (14) led matrix (6) line tracer (1) lm35 (1) lora (11) lorawan (2) MATV (1) memory (1) metal detector (4) microcontroller (70) micropython (6) mikrokontroler (2) mikrokontroller (14) mikrotik (5) modbus (9) mqtt (3) ninmedia (5) ntp (1) paket belajar (19) palang pintu otomatis (1) parabola (88) pcb (2) power (1) praktek (2) project (33) proyek (1) python (8) radio (28) raspberry pi (9) remote (1) revisi (1) rfid (1) robot (1) rpm (2) rs232 (1) script break down (3) sdcard (3) sensor (2) sharing (3) signage (1) sinyal (1) sms (6) software (18) solar (1) solusi (1) tachometer (2) technology (1) teknologi (2) telegram (2) telepon (9) televisi (167) television (28) telkomiot (5) transistor (2) troubleshoot (3) tulisan (94) tutorial (108) tv digital (6) tvri (2) vu meter (2) vumeter (2) wav player (3) wayang (1) wifi (3) yolo (7)

Arsip Blog

Diskusi


kaskus
Forum Hobby Elektronika