I want to read every 10 numbers of the serial read and to get the average of those numbers in arduino. in serial communication with arduino i want to take every 10 numbers from the serial communication and to display the average of those 10 numbers in arduino. Can anyone tell me how to do that in arduino? Thank You.
Related
I have an RDM6300 RFID writer/reader. It can read RFID Tags and it sends the data via UART to a microcontroller. So far I worked with multiple Microcontrollers from which ones the STM32F04 had the most UART "ports" (8 transmitters and receivers). The Arduino has got a few, but it is not enough.
I want to have 25 RFID readers (that are reading almost at the same time), but I can't find a way to send data from all the readers to one microcontroller.
Is there a way how can I connect 25 readers to ONE microcontroller?
You have 25 things transmitting at 9600 bps. You have an MCU running at 180 MHz with 8 UARTS and lots of timer capture channels (32 channels, 30 of them usable on the 100 pin STM32F427VITx). 8 of the 25 inputs are taken care of by the UARTS, 17 needs to be processed by other means. Connect them to timer capture channels.
The MCU runs at 180 MHz, the inputs change state at 9600 Hz, that means 18750 clock cycles between events. Should be way more than enough to process all of them, if you don't use HAL.
read the timer status register, check for capture events and clear them
check pin state, low means start of a frame
store the capture register value for that channel
keep checking for capture events
if there is one, clear it
read the capture timestamp, subtract the stored value from step 3 from it
calculate the number of bits received with identical state
keep doing it until you have 9 bits (start bit + 8 data bits) and high input on the pin
Do the above in parallel for all 17 channels. You need a suitable prescaler for the timers so they won't overflow while reading a full frame (9*18750=168750 cycles)
my port expander PCF8574 got the I2C Adress 0x38.
can someone tell me the Adresses of Port4 and Port5?
datasheet -> http://www.waveshare.com/wiki/PCF8574_IO_Expansion_Board
According to the datasheet you should be writing a byte with the bit set corresponding to your exapansion port. So if you want to set Port4 and Port 5 you should be writing a byte to the I2C wit bits 4 and 5 high. Ex:
Wire.beginTransmission(0x38);
Wire.write(b00110000);
Wire.endTransmission();
4th and 5th bits are sent high. Send 0s to pull it low. you should also read carefully the datasheet for all the subtleties.
I'm going to build a LED-Wall which i will control via 4 teensy micro controllers. Everywere I read the vertical number of my LEDs has to be a multiple of 8? Does it really have to be so?
Thank you
No.
The number 8 is the factor of number of output pins in a port of most digital electronics component (shifters, drivers etc) which assumes a output word to be 8 bits.
A port in a general purpose MCU or MPU will have 8 pins.
Thus the whole available pins can be utilised without wastage.
ATmega168P/328P in arduino, has 3 ports. PORTB, PORTC, and PORTD.
I want to use the readings off an LDR to dictate the sound. I know have to do this with a buzzer in my circuit and I know how to call my speakers in java, but I don't have any idea how to do this in Arduino.What I want exactly is something along the line of:
input = analog read(pin 6);
tone(LAPTOP SPEAKERS, input);
So you want to use laptop to play music? them your arduino will send a messagge to the PC (by Serial, Bluethoot, Wifi, Ethernet, smoke signal) and a pc program will read that signal and play the according sound.
Or you can use the arduino with a buzzer, or with a speaker jack, and use the tone() function, or a mp3 shield if you need specific sound.
You can send the readed value from pin6 over serial to pc , and use this value on java to generate a sound at this frequency. Send it over serial it's not a problem, it's so easy as Serial.print(input);, this will sent the readed value (0 - 255) to pc.
The main problem for me will be generate the tone at specific frequency on java, and it's not so hard.
i am using arduino uno , atmega328.
on analogRead on the analog pin A0 returns 0 when it is grounded, and with HIGH signal from another pin it returns some value around 1000. But when i connect it to a sensor which gives out around 26 mV it returns random values ...
YYY
My code is very basic, uses analogRead and display it in serial monitor.
A signal with fluctuations of 10mV is not random. The flucatuations are called noise. The standard approach is to add a low pass filter in hardware or software. Since you have a controller anyway I would go for software based low pass filtering. A simple and computational cheap but effective low pass filter is an exponential filter, also known as exponential moving average.