Draw image from live arduino sensor data - arduino

I want to draw real time graph using data coming from a rotating ultrasonic sensor through arduino. What are the tools or library required for this. I am using official arduino IDE using C language.

The Arduino itself can't really draw a plot, so you'll have to send the data to your computer using Serial communcation. Your computer can then draw a graph. There are two options:
Use an existing program
The easy way.
This official Arduino page has some example code for the program Processing, but I'm sure you can find a bunch of other examples and tutorials online.
Write it yourself
This is the difficult and fun way.
If you already know a programming language, great! Search some tutorials about how to connect your Arduino & how to plot data.
Otherwise, I recommend starting with Python, this is a good place to start.
Java
I have some old code written in Java that connects to the Arduino using the very easy JSSC library:
SerialPort port = new SerialPort("COM9");
port.openPort();
port.setParams(9600, 8, 1, 0);
byte b = port.readBytes(1)[0]; //read a single byte
port.writeByte(b); //write a single byte
Where you'd replace "COM9" with whatever port your Arduino is connected to, as displayed in the bottom right of the Arduino IDE.
Actually plotting the data would require another library, I see JFreeChart being recommend a lot online.

Related

What programming language can be used to code in Arduino IDE?

I'm in beginner level of learning Arduino. I want to know what programming language used in Arduino?
I've followed tutorials and tried some codes and then got outputs such as blink LED, knight_rider ,measure distance using ultrasound sensor & etc.
Here is a peice of code I learned in the tutorial for measure distance using ultrasound sensor.
`Serial.print`(inches);
`Serial.print`("in \t ");
`Serial.print`(cm);
`Serial.println`("cm");
When I searched google, It says C/C++ are used in Arduino. I have learnt Cand C#. But as far I know there is no function called println in C language. It confuse me what language is this?
From the Arduino FAQ:
Can I program the Arduino board in C? In fact, you already are; the
Arduino language is merely a set of C/C++ functions that can be called
from your code. Your sketch undergoes minor changes (e.g. automatic
generation of function prototypes) and then is passed directly to a
C/C++ compiler
From Wikipedia:
The Arduino IDE supports the languages C and C++ using special rules
of code structuring.
You can define your own functions in pretty much any programming language. That there is a function named println doesn't mean that it isn't C++ anymore.

MSP430 I2C slave to generate PWM signal , master is R-pi3

I need to code for a MSP430FR5969 launch pad that can generate PWM signal upto 100KHz, I want to control it with R-Pi3 over the I2C bus to send the Freq and duty cycle to the MSP430.
I am very new in coding MSP430, any help would be appreciate it.
thans
I find the best approach is to look at the examples provided for this particular LaunchPad. You'll now find these under Resource Explorer.
Run the PWM example and get your head around what it's doing. This should be easy enough using the on-board LED.
Then run the I2C example and get your head round what that's doing. You can connect it straight to the Pi, but a logic analyser will really help with this.
Peripheral setup is the hardest part of MSP430 coding. Once you get this right (or just copy it from an example) the code in between is normally much easier.

Is it possible to program Arduino boards using a few lines of assembly in the Arduino IDE?

I want to measure the time between two signals that are not in phase and i am using arduino Uno. I have converted the 2 sinusoidal signals into square waves and i am feeding them on INT0 and INT1 respectively. To measure the lag between the two signals i want to measure the time between the rising edges or falling edges of the signals using interrupts. On receiving the first rising edge i want to start a timer, say timer 3, upon receiving the second rising edge i want to stop the timer. my problem is i cant find a library that will allow me to start and stop timer the 3 and use the value it so i have chosen to include a few lines of Assembly language in my program for that purpose. Is it possible on the Arduino boards using the arduino IDE?
Yes it's possible. See for example this tutorial. However, I'd strongly recommend if you're doing anything more than a few instructions, you download and install Atmel studio -- which is free -- and use its excellent user interface to do your coding and debugging. I do all my programming for bare microcontrollers, in-system programming, and Arduinos using Atmel Studio.

Joystick USB definition for use with Arduino

I'm trying to write the control code for a custom joystick, and I cannot find any reference to what needs to be implemented to be recognized by a computer as a joystick.
I can see what things I need to have by referencing various game library APIs for using a joystick.
For example, pygame has the following methods,
init
quit
get_init
get_name
get_id
get_numaxes
get_numbuttons
etc.
My next stop is to read through the kernel for Linux's HID and joystick controlers... But this seems like a really round about way of finding this information.
I haven't worked with it, but it looks like there is some interesting information in Arduino Uno Joystick HID firmware and Arduino Uno Big Joystick HID firmware. There is also UnoJoy - I'd try that first (assuming you have an Arduino Uno or Leonardo).

36X12X12 LED Cube Hardware requirements?

Ive been trying to build a 32X12X12 LED cube (something like this http://www.youtube.com/watch?v=f1YNyQqbiF0 ) and trying to get some animation running on it. I used the Arduino to get a 8X8X8 cube running and i wanted to know:-
Is it possible to do the same with the Arduino (considering limited number of ports)?
If Yes, what additional hardware would i require? (Like Multiplexers and Shift Registers)
Is there a LED Driver or any other open source HW platform i could use to do this, that allows easy programming also?
I will multiplex your 3 questions into one answer: I recommend the MA72xx to drive your LEDs. You can drive up to 15 of them from your Arduino, which probably will suffice your 32x32x32 needs.

Resources