"Kembali Ke Dasar Elektronika Digital ... "

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

HP: 081331339072
Mail : ahocool@gmail.com

Site View

Categories

555 (6) 7 segmen (3) adc (4) amplifier (2) analog (10) android (11) antares (3) arduino (14) attiny (1) attiny2313 (17) blog (1) bluetooth (1) cmos (2) crypto (2) dasar (35) display (3) esp8266 (3) gcc (1) iklan (1) infrared (2) Input Output (3) iot (16) jam (6) jualan (12) kereta api (1) keyboard (1) keypad (3) kios pulsa (2) kit (6) komponen (12) komputer (3) komunikasi (1) kontrol (4) lain-lain (8) lcd (2) led (9) led matrix (6) line tracer (1) lm35 (1) memory (1) metal detector (4) microcontroller (55) mikrokontroller (7) mikrotik (5) ninmedia (1) ntp (1) paket belajar (19) palang pintu otomatis (1) parabola (29) pcb (2) praktek (2) project (33) proyek (1) python (1) radio (3) raspberry pi (4) remote (1) revisi (1) rfid (1) robot (1) rpm (2) rs232 (1) script break down (3) sdcard (3) sensor (1) sharing (3) signage (1) sms (6) software (18) tachometer (2) telepon (7) televisi (58) television (2) transistor (1) troubleshoot (3) tulisan (55) tutorial (78) tvri (1) vu meter (2) vumeter (2) wav player (3) wayang (1) wifi (3)

Arsip Blog

Diskusi


kaskus
Forum Hobby Elektronika