Tell us about yourself!
You can use Arduino's map() function:int result=map(ps2value, -127, 127, -255, 255);
Sorry, I misunderstood you original question.I've updated the library generally and changed it to use 'int' for the x and y variables. I've put the library on github (https://github.com/jazzycamel/PS2Mouse) to make it easier to distribute updates. Please be advised that I don't currently have the hardware setup to test it, so all bug fixes or problems gratefully received.
@MateuszK55I've now hooked up some hardware and tested everything actually works... and it does!Some interesting points to note are that: 1) despite now being able to handle the full -255 to 255 range, the mouse only ever sends -128 to 127! 2) The overflow bit never seems to be set! 3) The whole "4 counts per mm" is total rubbish and wildly inaccurate! All of these things may be due to a cheap mouse that I'm using to test this however...Anywho, I hope this is useful to you or someone :)
Also, I changed some of the method names to be more 'Arduino-y', so check the example (PS2Mouse.ino) to see whats changed.
Hi there,The 'click' data is actually part of the data returned from the mouse in the 'stat' byte returned from mouse_pos(). Have a look at this gist: https://gist.github.com/jazzycamel/c9e1f320d8fc709... for a brief example.Hope it helps :)
@geigercounter120If its any help to you, I have an example of using an Arduino, a DS18B20 and a solid state mains relay to control the temperature of a water boiler for use as a mash tun: https://github.com/jazzycamel/BoilerController.Thanks for your comment, good luck and have fun!
Hi there,Simple question: using pulseIn() are you not only measuring only the 'high' part of the square wave as opposed to the full period? If so, your frequency and thus your speed will be double the actual value. I may have missed something in your explanation though...
Ignore that, ive just reread the code and seen the conversion from μs to Hz is 500,000/time rather than 1,000,000. Might ne good to explain that somewhere. Also, the duty cycle of the square wave is 50% +/- 25% so you're probably better measuring edge to edge, as averaging the result won't compensate for continuously asymmetrical waveforms.
Good to know you've got it working, we'll done :) Glad I could help.
Hi @Tecwyn Twmffat,My Dad works for Vector Instruments (Windspeed) and was the guy who sorted out these instruments for you. I hooked up on the of Anemometers to a PIC micro ~4 years ago so feel free to give me a shout if I can be of any assistance (not that I think you'll need it!) :)Congratulations on a nice job well done :)
That should have been NUM_DS18B20, sorry!
That failure is right at the first step of communicating with the sensors, i.e. it's failing to find any and/or the right number of DS18B20's on the 1Wire bus. What model of Arduino are you using? Is NUM_BS18B20 set to the number of sensors you have connected?Also, a few things to check:1) Are all the connections the same or equivalent to those in my circuit diagram2) Are you using my tweaked version of OneWire.cpp? If not, you'll need to connect a 4.7kΩ pullup resistor between the 1Wire bus (pin 7) and VCC (you might try this anyway).This is just the first few things that come to mind. Try these and let me know the results, I hope you get it working :)
Glad I could be of some help :)