Netduino 101 : potentiometer example

December 19, 2012  |  Hardware, Netduino  |  , ,  |  1 Comment  |  Share

Things

potentiometer example takes analog input and light up leds accounting to the input 1023 divide by 5;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
namespace potentiometer_netduino
{
public class Program
{
public static void Main()
{
var voltagePort = new AnalogInput(Pins.GPIO_PIN_A1);
var lowPort = new OutputPort(Pins.GPIO_PIN_A0, false);
var highPort = new OutputPort(Pins.GPIO_PIN_A2, true);

OutputPort led1 = new OutputPort(Pins.GPIO_PIN_D1, false);
OutputPort led2 = new OutputPort(Pins.GPIO_PIN_D2, false);
OutputPort led3 = new OutputPort(Pins.GPIO_PIN_D3, false);
OutputPort led4 = new OutputPort(Pins.GPIO_PIN_D4, false);
OutputPort led5 = new OutputPort(Pins.GPIO_PIN_D5, false);

AnalogInput socket = new AnalogInput(Pins.GPIO_PIN_A5);

int INPUT=0;
while (true)
{
INPUT = socket.Read();
if (INPUT > 100 && INPUT <= 200) {
led1.Write(true); led2.Write(false);
led3.Write(false); led4.Write(false);
led5.Write(false);
}
else if (INPUT > 200 && INPUT <= 400) {
led1.Write(true); led2.Write(true);
led3.Write(false); led4.Write(false);
led5.Write(false);
}

else if (INPUT > 400 && INPUT <= 600) {
led1.Write(true); led2.Write(true);
led3.Write(true); led4.Write(false);
led5.Write(false);
}
else if (INPUT > 600 && INPUT <= 800) {
led1.Write(true); led2.Write(true);
led3.Write(true); led4.Write(true);
led5.Write(false);
}
else if (INPUT > 800 && INPUT <= 1000) {
led1.Write(true); led2.Write(true);
led3.Write(true); led4.Write(true);
led5.Write(true);
}
else if (INPUT < 100) {
led1.Write(false); led2.Write(false);
led3.Write(false); led4.Write(false);
led5.Write(false);
}
Debug.Print(INPUT + " ");
}
}
}
}

Arduino vs Netduino : the more things change, more they remain same.

December 19, 2012  |  Hardware, Netduino  |  ,  |  No Comments  |  Share

netduinoArduino and Netduino are kinda of like small computers that have allowed us to do marvelous things, like controlling our environment and more they are not really that expensive Arduino mega 2560 is 7k and Netduino plus is 5k, if you have not heard of this before, this article is not really for you.

I recently got new Netduino Plus thanks to my sir for lending it to me, and I have been playing with it. I have done few small Arduino projects so far, so I was interested in seeing how they were all that different. I have to say, I was very impressed with it, but there are differences you should know about before you jump into using a Netduino.

The basic difference is Netduino is C# based on .net for programming liking the intellisense part a lot, and Netduino is 48MHz where as Arduino has 16MHz, both are open source.

The Netduino board is the same size and shape as an Arduino UNO board. There is a place to install a 6-pin header at the back of the board, though no header is installed, in the same spot Arduinos have a similar header. The TX and RX monitor LEDs that Arduinos have do not exist on the Netduino.

Netduino IDE only works on windows as you might have expected that by now, but you can setup the entire IDE for free, you will have to use visual studio 2010, which is easy to use.

Netduino has very good debugging environment, we can emulation and in circuit debugging(like any C# program which breakpoints and stuff) which is really great unlike Arduino, when you start debugging it downloads the code in Netduino and stops at the breakpoint so you can check each line while debugging.

Netduino does support the option to program it in Visual Basic but i prefer C#, Intellisense FTW. Here are some of difference between Netduino Plus and Arduino Mega 2560 Rev 3.

Category Difference
 Chip power  Internally, the CPU runs at 3.3V, not 5V like the Arduino, though it uses the same power sources
 Digital I/Os  Go from 0V to 3.3V, not 5V.  It will work with most 5V logic circuits, input and output.
 Analog Inputs  Must not go higher than 3.3V!
 PWM Outputs  PWM is often used like an analog output.   Since 100% averages to 3.3V instead of 5V, circuits may work differently
 Libraries  None of the Arduino libraries, which are C and C++ code, will work on the Netduino without modification.  If you use a board-specific library, you may have to rewrite it.
USB Connector  Uses cell-phone type mini USB connector
 I/O Current  The pins on the CPU can drive a maximum of 8mA of current, which is less than Arduino
 CPU  32-bit Atmel ARM, instead of 8-bit ATmega
 Speed  48MHz instead of 16MHz
 Program Memory  128K instead of 256K
 RAM  60K instead of 8K
 EEPROM  Netduino has none
 In-circuit debugging  Netduino has it
 Emulation  Netduino development environment has it

if you are making a project that requires a lot of processing power and awesome debugging environment than get yourself Netduino, if you want to use Arduino shields and libraries then Netduino is not for you.

Getting Started
Here are some links to get you started on Netduino:

Netduino Site
Netduino Getting Started PDF
Atmel Microcontroller Data
Atmel Microcontroller Full Datasheet
Netduino Schematic
Netduino Forums

Development Software
Microsoft Visual C# Express 2010
.NET Micro Framework SDK v4.1
Netduino SDK v4.1 (32-bit)
Netduino SDK v4.1 (64-bit)
.NET Micro Framework Reference

Requirement list

This is basic things i have at my dissposal, list you will need to follow my experiments, if you have any suggestion do comment

ITEM
ARDUINO MEGA 2560 Rev3
Bluetooth Serial Module
TRANSISTORS (C945)
RESISITANCE (330 ohm )
RESISITANCE ( 10k )
BREAD BOARD
JUMPER CABLES or WIRES
Relay 6V
PRINTER CABLE
ANDROID PHONE
ARDUINO WIFI SHIELD
7805 12V TO 5V
5V DC ADAPTER
100 OHM RESISTANCE
BLUETOOTH RN42 SMD
NETDUINO
9V BATTERY
9V BATTERY STRAP
VERO BOARD

for now I guess that’s it.

My Jarvis

Jarvis, the one from iron man movie, Yes, Digital Life Assistance crazy idea for hobby project, right ? well we have seen many different kind’s of implementation’s in hope’s of achieving what that rich bastard has, but if we were to have it, we must first have platform to build upon, as far as I can see we need a system which is capable of achieving tasks in real world and virtual world, so to start off my first task is controlling the lights with Arduino, don’t worry I will be taking it slow. Idea, if it was not clear above,  idea is to use Arduino without spending a lot of money(very crucial) to control devices such as bulbs, fans and stuff,  I plan on using some sort of communication shield, When done it will send some MESSEAGE(not really clear on that) to Arduino, Arduino will move some relays and give me back a  response, toggling devices.

next post will be about requirements and basic concept of controlling a device through relay.

Arduino: toggling leds through SERIAL monitor

ok here is a sample code which receives data from serial and toggles devices to test it you can plug in led’s to test it,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//for keeping the current status of leds
int status1 = 0;
int status2 = 0;
int status3 = 0;
int status4 = 0;
//leds connected to Arduino int pin1 = 2;
int pin2 = 4;
int pin3 = 6;
int pin4 = 8;
void setup() {
//open serial ports
Serial.begin(9600);
Serial.println("Serial Ready.");
Serial.println("Waiting...");
//open led ports
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
}
void loop() {
//keep the incoming byte, in readByte
int readByte;
boolean readSomething = false;
//read serial data
while(Serial.available() > 0 ){
readByte =  Serial.read();
readSomething = true;
Serial.println(readByte);
}
//if something was read toggle the selective device
if(readSomething){
readSomething = false;
if(readByte==1){ status1^=1; digitalWrite(pin1,status1);}
if(readByte==2){ status2^=1; digitalWrite(pin2, status2);}
if(readByte==3){ status3^=1; digitalWrite(pin3, status3);}
if(readByte==4){ status4^=1; digitalWrite(pin4, status4);}
}// status^=1 is xoring if its 0 it will be 1 and if its 1 it will be 0..
}

I think therefore; I am.

September 27, 2012  |  days in life  |   |  No Comments  |  Share

That is contradictory right?, well I am because of God. A little about myself people think of me bossy and a jerk, well they are wrong, and head up, I am narcissist, perfectionist, obsessive compulsive, bit weird but you will love me.