Arduino Distance sensor as an input ?

Hello All ! 

I have got a HC-SR04 Ultrasonic sensor wired up with an arduino. 
Using the NewPing Library code I can get a read-out value in the serial window of milliseconds or centimetres. But I cannot figure out how to use MilliuminStream to send this data to Milliumin. 
I've attached a picture of my code. (I am sure that I have got all of the MilliuminStream code wrong, so sorry in advance !)

Best Wishes,
Arran,
ard.png 250.7K

Comments

  • Hello @Arran22

    Regarding your code, they are two things that looks wrong. 

    MilluminStream is using serial communication under the hood. So starting a new Serial and sending values is jamming the communication. 

    Commenting the "Serial.begin(9600);" and "Serial.println(...);" might solve the communication. 
    Also, you are defining the pin 13 as an ouptut, wich is not necessary in the snippet you are showing. 

    To ensure that the communication is working ok, you can try the "auto upload" function shipped with Millumin latest beta. 

    Please let us know if it solves your problem. 

    Regards.

    --
    AntoineM*
  • Works great now ! thanks Antoine.

    I will tidy up my code and share it in a new thread for others to use. 

    All the best,
    Arran.
  • Hi Arran,
    I'm interested in using this type of sensor. Wondering if you may have posted the 'tidy'd up' code you were able to get working?
    Thanks
    Kathleen

Sign In or Register to comment.