Show Posts
Pages: 1 [2] 3 4 ... 64
16  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 05:04:05 am
I already tried it. It gives expression expected error
17  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 04:22:37 am
Code:
Imports System.IO
Imports System.IO.Ports
Imports System.Threading

Public Class Form1
    Shared _continue As Boolean


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.Close()
        SerialPort1.PortName = "COM3"

        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.Handshake = IO.Ports.Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default 'very important!

    End Sub


    Private Sub Button1_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_Click.Click
        SerialPort1.Open()
        SerialPort1.Write("1")
        SerialPort1.Close()
    End Sub



    Private Sub Button2_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2_Click.Click
        SerialPort1.Open()
        SerialPort1.Write("0")
        SerialPort1.Close()
    End Sub



End Class


Arduino CODE
Code:
int ledPin = 2; // the number of the LED pin

void setup() {
Serial.begin(9600); // set serial speed
pinMode(ledPin, OUTPUT); // set LED as output
digitalWrite(ledPin, LOW); //turn off LED
}


void loop(){
while (Serial.available() == 0); // do nothing if nothing sent
int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number

if (val == 1) { // test for command 1 then turn on LED
Serial.println("LED on");
digitalWrite(ledPin, HIGH); // turn on LED
}
else if (val == 0) // test for command 0 then turn off LED
{
Serial.println("LED OFF");
digitalWrite(ledPin, LOW); // turn off LED
}
else // if not one of above command, do nothing
{
//val = val;
Serial.println("Wrong command");
}
Serial.println(val);
Serial.flush(); // clear serial port
}

For below code i am getting error. please let me know what i need to do. I got everything configure right manner
18  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 02:46:08 am
I have tried with processing . I dont how to create Serial data block  like  VB and display there.
I have 2 perameter

1) I have sensor that read analog 0~5v and Converted to current value . which is serial printed on either VB or processing,
2) I have digital pin if check button led must glow and if uncheck it must get off.

To understand or implimenting i need help.
I have Tried with Serial Monitor itself i.e Sending data over Serial monitor and control It . IT working fine for me.
I can control the  led , off led.
Below code working fine.

Code:
int led=2;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(led,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 
  while(Serial.available()==0);
  int val=Serial.read()-'0';
  if (val==1)
  {
    Serial.println("Led is ON");
    digitalWrite(led,HIGH);
   
  }else
  {
   Serial.println("Led is OFF");
    digitalWrite(led,LOW);
  }
 
 
}
19  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 02:24:20 am
As i said I am new to visual basic , I am trying to get some data for learning so i can proceed further. Once i make ensure serial communication work. I can modify that code.

@Robin 2
My code i pasted on top. I am printing just hello. I wanted to display it on text dialogue box.
I have followed step by step process given by multiwing
http://www.multiwingspan.co.uk/arduino.php?page=vb1
But i am facing some problem.


What does it means??
Code:
What makes your textBox code read the serial port?

When, and how often, does that happen?
20  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 01:43:34 am
I can t see any thing here.
http://www.multiwingspan.co.uk/arduino.php?page=vb1
i tried this code but i didint get any thing also.It dont allow me to select port and set baudrate . if enter manually it can take input. But not receiving any data

Code:

Imports System.IO.Ports


Public Class Form1


    Dim WithEvents sp As New SerialPort



    Private Sub GetSerialPortNames()
        For Each sport As String In My.Computer.Ports.SerialPortNames
            cmbPort.Items.Add(sport)
        Next
    End Sub

    Sub ShowString(ByVal myString As String)
        textln.AppendText(myString)
    End Sub


    Delegate Sub myMethodDelegate(ByVal [text] As String)
    Dim myDelegate As New myMethodDelegate(AddressOf ShowString)











    Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
        Try
            sp.BaudRate = cmbBaud.SelectedItem.ToString
            sp.PortName = cmbport.SelectedItem.ToString
            sp.Open()
            If sp.IsOpen Then
                btnConnect.Visible = False
                cmbport.Enabled = False
                cmbBaud.Enabled = False
                btnDisconnect.Visible = True
            End If
        Catch
            sp.Close()
        End Try
    End Sub

    Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
        Try
            sp.Close()
            btnConnect.Visible = True
            btnDisconnect.Visible = False
            cmbport.Enabled = True
            cmbBaud.Enabled = True
            Exit Sub
        Catch
            MessageBox.Show("Some kind of problem.")
        End Try
    End Sub




    Private Sub cmbport_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbport.SelectedIndexChanged
        Dim BaudRates() As String = {"300", "1200", "2400", "4800", "9600", "14400", "19200", "28800", "38400", "57600", "115200"}
        cmbBaud.Items.AddRange(BaudRates)
        cmbBaud.SelectedIndex = 4
        Try
            GetSerialPortNames()
            cmbport.SelectedIndex = 0
        Catch
            MsgBox("No ports connected.")
        End Try
    End Sub



    Private Sub textln_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textln.TextChanged
        Dim str As String = sp.ReadExisting()
        Invoke(myDelegate, str)
    End Sub
End Class


21  Using Arduino / Interfacing w/ Software on the Computer / VIsual basic with arduino on: September 16, 2014, 12:55:07 am
Dear all,

I am trying to display the data get from arduino on Visual serial monitor.

I have created text box . and here my code. It not displaying anything.

Arduino CODE:

Code:
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("welcome");
 
  delay(1000);
}


visual basic

Code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' baudrate = 9600'
        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.PortName = "COM3"

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        Dim s As String
        s = SerialPort1.ReadLine()
        TextBox1.Text = s


    End Sub
End Class



22  Using Arduino / Project Guidance / Re: Processing for Arduino on: September 15, 2014, 11:11:15 pm
Can some one let me Know Where i can find working Proecssing and firmdata.

http://playground.arduino.cc/interfacing/processing.

I am getting below error. I have upload the blink example code from arduino and example code from processing .

As i said i unzip folder and kept in sub folder liberries of processing. But i found it not being detected here,

Please let me know what else need to be done
23  Using Arduino / Project Guidance / Re: Processing for Arduino on: September 15, 2014, 07:02:24 am
Is it possible to give some example code here. Code to be uploaded in arduino. and code to be scripted on processing.
24  Using Arduino / Project Guidance / Re: Processing for Arduino on: September 15, 2014, 06:54:32 am
I dont know how processing work.

I am thinkling like this way. If i make customised tag  say as shown in above example if  click any button it should make changes via PC. Control input are given from PC for digital IOS of arduino. IF  highlighted make digital pin high else if pressed again not highlighted make it low

25  Using Arduino / Project Guidance / Re: Processing for Arduino on: September 15, 2014, 06:51:02 am
Here my processing code. I just want to enable 13 pin. If enable blink 13 pin high else low make led off.
Code:

import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

color off = color(4, 79, 111);
color on = color(84, 145, 158);

int[] values = { Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
 Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW,
 Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW, Arduino.LOW };

void setup() {
  size(470, 200);
  
  // Prints out the available serial ports.
  println(Arduino.list());
  
  // Modify this line, by changing the "0" to the index of the serial
  // port corresponding to your Arduino board (as it appears in the list
  // printed by the line above).
  arduino = new Arduino(this, Arduino.list()[0], 9600);
  
  // Alternatively, use the name of the serial port corresponding to your
  // Arduino (in double-quotes), as in the following line.
  //arduino = new Arduino(this, "/dev/tty.usbmodem621", 57600);
  
  // Set the Arduino digital pins as outputs.
  for (int i = 0; i <= 13; i++)
    arduino.pinMode(i, Arduino.OUTPUT);
}

void draw() {
  background(off);
  stroke(on);
  
  for (int i = 0; i <= 13; i++) {
    if (values[i] == Arduino.HIGH)
      fill(on);
    else
      fill(off);
      
    rect(420 - i * 30, 30, 20, 20);
  }
}

void mousePressed()
{
  int pin = (450 - mouseX) / 30;
  
  // Toggle the pin corresponding to the clicked square.
  if (values[pin] == Arduino.LOW) {
    arduino.digitalWrite(pin, Arduino.HIGH);
    values[pin] = Arduino.HIGH;
  } else {
    arduino.digitalWrite(pin, Arduino.LOW);
    values[pin] = Arduino.LOW;
  }
}


Arduino code
Code:

int led1=13;
int IN=2;
void setup()
{
 Serial.begin(9600);
pinMode(led1, OUTPUT);  
pinMode(IN, INPUT);  
}

void loop()
{
  
  if(Serial.available()>0)
  {
  if (digitalRead(IN)==1)
  {
    digitalWrite(led1,HIGH);
  }else
  {
     digitalWrite(led1,LOW);
  }
  }
  
  
}

26  Using Arduino / Project Guidance / Re: How to get proceessing data in arduino on: September 15, 2014, 06:32:57 am
I wanted to know How to get data from analog port and display converted value on Monitor via processing.

I want to controll digital IO. IF click it pin should be high, Else it should be low.
27  Using Arduino / Project Guidance / How to get proceessing data in arduino on: September 15, 2014, 06:18:10 am
Dear all,
http://forum.arduino.cc/index.php?topic=266922.msg1882171#msg1882171

Is any one know how to do it. Is there any example code for processing where i get data
28  Using Arduino / Project Guidance / Re: Processing for Arduino on: September 15, 2014, 05:39:19 am
Code:
import processing.serial.*;
import cc.arduino.*;

Arduino arduino;
int ledPin = 13;

void setup()
{
  //println(Arduino.list());
  arduino = new Arduino(this, Arduino.list()[0], 57600);
  arduino.pinMode(ledPin, Arduino.OUTPUT);
}

void draw()
{
  arduino.digitalWrite(ledPin, Arduino.HIGH);
  delay(1000);
  arduino.digitalWrite(ledPin, Arduino.LOW);
  delay(1000);
}

How to run this processing code. I got example from below link
http://playground.arduino.cc/interfacing/processing


@c-f-k
Yes i wanted to read value as it converted. Here is my actual code. If rellay got tripped some  red bulb shold triggered else green bulb to be triggered. If any fault manually operated by selecting switch. This code not complete. Indivually working  fine.
But if there fault light should be red on processing else it should go green, Some digital pin to control these pins


Code:
#include <MsTimer2.h>

#define RELAY1  7
#define RELAY2  6
#define MAX_TRIP_COUNT  5
float Current_Limit=0.60;
int newaverage;
float Output_Current;
static int Trip_Count=0;
static int Tripped_Flag=1;
int led = 13;
#include <avr/wdt.h>


void TakeReading()
{
 newaverage = analogRead(A5);
 Serial.print("count:");
 Serial.println(newaverage);
Output_Current = 0.0336666666667*newaverage - 17.17;
}
void Relay_Activate()
{
  for (unsigned long start = millis(); millis() - start < 10000;)
  {
    digitalWrite(RELAY1,HIGH);
    digitalWrite(RELAY2,HIGH);
    Serial.println("RELAY GOT TRIPPED");
    Tripped_Flag=0;
    Trip_Count=0;
  }

}

void  Relay_Deactivate()
{
  digitalWrite(RELAY1,LOW);
  digitalWrite(RELAY2,LOW);
  Serial.println("RELAY NOT TRIPPED");
  Tripped_Flag=1;

}

void Relay_Intialize()
{
  Serial.println("RELAY GOT INTIALISE....");
  digitalWrite(RELAY1,LOW);
  digitalWrite(RELAY2,LOW);
}


void setup()
{
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(RELAY1,INPUT);
  wdt_enable(WDTO_8S);
  Relay_Intialize();
}

void loop()
{
// MsTimer2::set(1000, TakeReading); // 500ms period
// MsTimer2::start();
wdt_reset();
TakeReading();
 Serial.print("Output_Current:");
 Serial.println(Output_Current);
 if(Output_Current>Current_Limit)
 {
   
     Trip_Count=Trip_Count+1;
     Serial.print("Trip_Count:");
    Serial.println(Trip_Count);
    if(Trip_Count>=5)
   {
     Relay_Activate();
   }
 }else
 {
   if(Trip_Count<=0)
   {
     Trip_Count=0;
   }else
   {
   Trip_Count=Trip_Count-1;
   }
   
   Relay_Deactivate();
   Serial.print("Trip_Count:");
    Serial.println(Trip_Count);
   
 }
 
 Serial.println(".......................");
/* digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);
 */
 
 
 delay(2000);
 
}





29  Using Arduino / Project Guidance / Re: Processing for Arduino on: September 15, 2014, 05:26:01 am
I dont know how to do it.

I need to collect data serially from arduino display on processing. If i say digital pin high in sogtware it must activate the relay or bulb which connected to arduino board @ interface. It should keep reading analog  converted values coming serially trhrough program as mentioned above.

I have only 2 perameter
1) control the relays
2) to read sensor values.

If you have any example code or software share links. I am having visual studio software.
30  Using Arduino / Project Guidance / Processing for Arduino on: September 15, 2014, 05:17:05 am
Dear all,

I am searching for Processing software that can interface with arduino . Main agenda is to collect data from Serial and analog port and also need to control digitals ios high or low.

Is any software avilable Where i can control My Arduino IOS , see the Serial output data, Read analog value .

In below code my pin connected to analog pin 5. I wanted to show on display screen only output current value. How can i show it???
Code:
void TakeReading()
{
 newaverage = analogRead(A5);
 Serial.print("count:");
 Serial.println(newaverage);
Output_Current = 0.0336666666667*newaverage - 17.17;
}

I have digital Pins say s 5 . through software i wanted to control  pin high or Low, so led start glowing. is any software readily avilable???
If available let me know.
Pages: 1 [2] 3 4 ... 64