0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« on: December 17, 2009, 12:28:22 pm » |
hello,i`ve just buyed Arduino Mega Kit,but i`ve never worked with it and i want to ask if someone could give me an example program to visualize some data on PC through USB interface...it doesn`t matter what data would be power,current or voltage
thank you !!!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #1 on: December 17, 2009, 12:40:53 pm » |
Hi Dimitar. If you start the arduino IDE, open file->examples->communication->Graph and read the text in that sketch. The sketch also gives code for processing ( http://processing.org/) and Max/MSP as programs for on your computer. Jeroen
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #2 on: December 17, 2009, 04:02:44 pm » |
Thank you for the previous info. I saw the materials witch you point me but because I'm a beginner I couldn't handle myself.If this doesn't bother you could you give me the program ( code) and its algorithm with witch to visualize the value of Power.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #3 on: December 17, 2009, 05:24:58 pm » |
I (we) will help you with problems as they arise but i will not write your code. ...witch to visualize the value of Power. Power of what? Can you explain what it is that you want to accomplish? Jeroen
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #4 on: December 17, 2009, 05:40:07 pm » |
i want to visualize on my pc connected to the board with usb interface voltage from some analog input
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #5 on: December 18, 2009, 04:29:57 am » |
Ok. If you try what i explained in reply 1 what is the first problem you have?
Jeroen
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #6 on: December 18, 2009, 04:40:42 am » |
i can`t find the source code(program) to visualize voltage
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #7 on: December 18, 2009, 05:37:35 am » |
It's between /* Processing code for this example and xPos++; } } } */ In the arduino sketch i pointed you to. You should copy/paste that to the processing program on the pc and remove what is highlighted below. [glow]/* Processing code for this example[/glow] .. .. .. .. // increment the horizontal position: xPos++; } } } [glow]*/[/glow] Probably a better advice would be to experiment with some (all) of the examples (like digital->blink) before you do a 'full project' to learn some programming/syntax. While it seems that that doesn't help you with your goal it is actually vitally important. Jeroen
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #8 on: December 18, 2009, 06:28:12 am » |
is this the program(cod) I need to visiolize the voltage
/* Processing code for this example // Graphing sketch // This program takes ASCII-encoded strings // from the serial port at 9600 baud and graphs them. It expects values in the // range 0 to 1023, followed by a newline, or newline and carriage return // Created 20 Apr 2005 // Updated 18 Jan 2008 // by Tom Igoe import processing.serial.*; Serial myPort; // The serial port int xPos = 1; // horizontal position of the graph void setup () { // set the window size: size(400, 300); // List all the available serial ports println(Serial.list()); // I know that the first port in the serial list on my mac // is always my Arduino, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[0], 9600); // don't generate a serialEvent() unless you get a newline character: myPort.bufferUntil('\n'); // set inital background: background(0); } void draw () { // everything happens in the serialEvent() } void serialEvent (Serial myPort) { // get the ASCII string: String inString = myPort.readStringUntil('\n'); if (inString != null) { // trim off any whitespace: inString = trim(inString); // convert to an int and map to the screen height: float inByte = float(inString); inByte = map(inByte, 0, 1023, 0, height); // draw the line: stroke(127,34,255); line(xPos, height, xPos, height - inByte); // at the edge of the screen, go back to the beginning: if (xPos >= width) { xPos = 0; background(0); } else { // increment the horizontal position: xPos++; } } } */
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #9 on: December 18, 2009, 06:34:57 am » |
Yep. That's the code to paste in processing on your pc. Remember to remove the lines that are highlighted in reply 7.
Jeroen
edit: If you post code please use the #-button.
|
|
|
|
« Last Edit: December 18, 2009, 06:37:24 am by Yot »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #10 on: December 18, 2009, 06:41:19 am » |
is this the program(cod) ?
// Graphing sketch
// This program takes ASCII-encoded strings // from the serial port at 9600 baud and graphs them. It expects values in the // range 0 to 1023, followed by a newline, or newline and carriage return
// Created 20 Apr 2005 // Updated 18 Jan 2008 // by Tom Igoe
import processing.serial.*;
Serial myPort; // The serial port int xPos = 1; // horizontal position of the graph
void setup () { // set the window size: size(400, 300);
// List all the available serial ports println(Serial.list()); // I know that the first port in the serial list on my mac // is always my Arduino, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[0], 9600); // don't generate a serialEvent() unless you get a newline character: myPort.bufferUntil('\n'); // set inital background: background(0); } void draw () { // everything happens in the serialEvent() }
void serialEvent (Serial myPort) { // get the ASCII string: String inString = myPort.readStringUntil('\n');
if (inString != null) { // trim off any whitespace: inString = trim(inString); // convert to an int and map to the screen height: float inByte = float(inString); inByte = map(inByte, 0, 1023, 0, height);
// draw the line: stroke(127,34,255); line(xPos, height, xPos, height - inByte);
// at the edge of the screen, go back to the beginning: if (xPos >= width) { xPos = 0; background(0); } else { // increment the horizontal position: xPos++; } } }
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #11 on: December 18, 2009, 06:46:05 am » |
Have you tried? What did it do? You actually have to do something yourself.
Jeroen
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 7
Arduino rocks
|
 |
« Reply #12 on: December 18, 2009, 07:02:23 am » |
I haven't got any knowledge of this program but I've been assign a task to visualize the voltage. Can I use a ready code from somewhere, coz I can't write it by myself.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
The Netherlands
Offline
Sr. Member
Karma: 1
Posts: 287
don't panic...
|
 |
« Reply #13 on: December 18, 2009, 07:21:29 am » |
If you spend a couple of hours reading the examples in the arduino IDE and processing IDE you will have the knowledge to do what you want by copy/pasting.
If you don't want to do that then the simplest way of 'visualize the voltage' will probably a multimeter.
Jeroen
|
|
|
|
|
Logged
|
|
|
|
|
|