Show Posts
|
|
Pages: [1] 2 3 ... 5
|
|
5
|
Using Arduino / Project Guidance / Re: Seeking advice on photoresistor led sequence project
|
on: October 18, 2012, 05:29:13 am
|
Hello cisco87, you can simply trigger the sequence by reading the photoresistor: void loop() { int lightLevel = analogRead(lightPin);
// ...
if( lightLevel < lowThreshold ) { inAndOut(); } else { // ... } }
consider that the analog channel is read when the "inAndOut" function completes its execution, once evey 6*100 = 600 millisec.
|
|
|
|
|
8
|
Using Arduino / Project Guidance / Re: Interfacing arduino to Power Point
|
on: October 06, 2012, 10:51:16 am
|
Is there a way where I can do something using C++, and which languages would you recommend I learn for being able to interface embedded hardware with windows or other operating systems, where I can control the programs in the OS using the hardware I build
Yes, you can program in C++ but some knowledge of Windows environment is necessary (WIN32, MFC, COM), here is explained how to do an MFC application to automate Power Point using MFC (Microsoft Foundation Classes): http://support.microsoft.com/kb/237554/en-us?fr=1If you learn how to open a serial port on Windows and read/write data, you can easily create a communication link between Arduino and a client application on the PC. If you already know C++ and object oriented programming, I suggest you to learn C# language for programming Windows applications.
|
|
|
|
|
9
|
Using Arduino / Project Guidance / Re: Interfacing arduino to Power Point
|
on: October 05, 2012, 07:56:26 am
|
Now I know arudino can send data to the serial port of the pc, but how can I interface the serial port to power point? Hi, if you know any .NET programming language (i.e. VB, C#) there is an easy way for controlling a power point presentation from code: string presPath = "c:/Temp/test_pps.ppt"; //Create an instance of PowerPoint. Microsoft.Office.Interop.PowerPoint.Application app = new Microsoft.Office.Interop.PowerPoint.Application();
// Show PowerPoint. app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
// Open a presentation. Microsoft.Office.Interop.PowerPoint.Presentations ppPres = app.Presentations; Microsoft.Office.Interop.PowerPoint.Presentation pres = ppPres.Open(presPath, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
// Show presentation. pres.SlideShowSettings.Run();
// Here read a command from serial port (for example the ASCII char 'N' for next and 'P' for previous) and call // pres.SlideShowWindow.View.Next(); or pres.SlideShowWindow.View.Next();
The previous code is in C# and some exception control should be added but is an example.
|
|
|
|
|
10
|
Using Arduino / Programming Questions / Re: Arduino and BV20 Bill Acceptor/Validator
|
on: October 01, 2012, 09:09:29 am
|
After I inserted a $5 bill that's what I got in Serial Monitor:
Code: -2726 12526 20487 31807 -21701 -7533 5954 18410 31594 -20286 -7357 5292 16138
One line every 3 seconds.
these numbers probably are due to the fact that a lot of interrupts are received and the gCount variable reachs the maximum (32767) and rolls over with negative numbers. Have you got an oscilloscope to verify the output line of your device?
|
|
|
|
|
11
|
Using Arduino / Programming Questions / Re: Arduino and BV20 Bill Acceptor/Validator
|
on: October 01, 2012, 03:28:17 am
|
Hi, your hardware setup should be: // o +5V // | // R = 2200 ohm // | // BV out o-------+-------o Arduino in // and I suggest you try to monitor the digital edges count: volatile int gCount = 0; unsigned long gMillisCounter;
void setup() { Serial.begin(9600); attachInterrupt(0, pulseCounter, FALLING); // On digital pin 2 gMillisCounter = millis(); }
void loop() { // Print gCount every 3 seconds if( (signed long)( millis() - gMillisCounter ) >= 0) { gMillisCounter += 3000; Serial.println(gCount); } }
void pulseCounter() { gCount ++; }
|
|
|
|
|
12
|
Using Arduino / Programming Questions / Re: Does the Arduino clock frequency affect analogRead()?
|
on: October 01, 2012, 01:40:20 am
|
Hi, are you sure the equation for calculating the resistance is correct? From the schematics in your code: // Configuration: // 5v------10k-------Sensor------GND // | // Analog
it should be: float aread = 5.0 * (analogRead(0) / 1024.0) // voltage in Volts float resistance = (10000 * aread) / (5.0 - aread); // resistance in ohm
|
|
|
|
|
13
|
Using Arduino / Programming Questions / Re: float type format
|
on: September 26, 2012, 02:05:41 pm
|
Hi fnsnoop, if the println function expects a NULL terminated string as parameter, this code Serial.println((char *)&number); can give problems because you are pointing a memory area whose content, after the 4 bytes of the number variable, in unknown.
|
|
|
|
|
14
|
Using Arduino / Programming Questions / Re: Convert Fixed-point to actual value(decimal)
|
on: September 26, 2012, 01:36:35 pm
|
|
Hi, if I have understood, you want to store the "actual value", in the range (0.0, 150.0), into a 32 bit integer with three decimal points by multiplying this number by 1000. Therefore you have an integer number in the range (0, 150000). An unsigned integer, 32 bit, can store any number between 0 and 4294967295, so I don't see any problem.
|
|
|
|
|
15
|
Using Arduino / Programming Questions / Re: Problem with a custom library
|
on: September 26, 2012, 04:32:00 am
|
Hi hjavaher, the code you posted is unusual also for the following reasons: 1) usually an header file content is inserted in a define block to avoid multiple inclusions, in this way: #ifndef __lib_gravity__ #define __lib_gravity__ ..... #endif
but the define directive is missing. 2) why are you including .c files in a header?
|
|
|
|
|