# Mios8 with C,  initial read all inputs once after the start of mios automaticly ?

**URL:** <https://forum.midibox.org/t/mios8-with-c-initial-read-all-inputs-once-after-the-start-of-mios-automaticly/21203>\
**Category:** MIOS programming (C)\
**Created:** [November 20, 2023, 10:08pm UTC](https://forum.midibox.org/t/mios8-with-c-initial-read-all-inputs-once-after-the-start-of-mios-automaticly/21203 "2023-11-20T22:08:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranger930](https://forum.midibox.org/letter_avatar_proxy/v4/letter/r/a698b9/32.png) [@ranger930](https://forum.midibox.org/u/ranger930)\
**Post date:** [November 20, 2023, 10:08pm UTC](https://forum.midibox.org/t/mios8-with-c-initial-read-all-inputs-once-after-the-start-of-mios-automaticly/21203/1 "2023-11-20T22:08:00Z")

</div>

Hello mios friends,

I have a midi controller based on a PIC18F452 and have programmed it in C.  
Is there a routine after starting the operating system that can read all inputs once and send the determined values as midi out (without turning a potentiometer or pressing a button)?

br ranger930

---

<div class="post-metadata">

**Author:** ![T.K](https://forum.midibox.org/user_avatar/forum.midibox.org/t.k/32/7_2.png) [@T.K](https://forum.midibox.org/u/T.K)\
**Post date:** [November 26, 2023, 8:11pm UTC](https://forum.midibox.org/t/mios8-with-c-initial-read-all-inputs-once-after-the-start-of-mios-automaticly/21203/2 "2023-11-26T20:11:59Z")

</div>

Hi,

you could send values from the Tick() hook - by using a static variable you can ensure that the values will only be sent once after startup.

Something like this (untested code)

```
///////////////////////////////////////////////////////////////////////////// // This function is called by MIOS in the mainloop when nothing else is to do ///////////////////////////////////////////////////////////////////////////// void Tick(void) \_\_wparam { static unsigned char ain\_sent = 0; if( ain\_sent == 0 ) { unsigned char pin; unsigned char num\_ain = MIOS\_AIN\_NumberGet(); ain\_sent = 1; // only sent once after startup for(pin=0; pin \< num\_ain; ++pin) { MIOS\_MIDI\_TxBufferPut(0xb0); // CC at channel 1 MIOS\_MIDI\_TxBufferPut(pin); // pin number corresponds to CC number MIOS\_MIDI\_TxBufferPut(MIOS\_AIN\_Pin7bitGet(pin)); } } }

```

Best Regards, Thorsten.
