Arduino, potenciometro y C#
http://thebatzuk.org/2011/06/arduino-potenciometro-puerto-serial-y-c.html
Utilizar jQuery en blogger
Editar la plantilla y agregar este código lugo del <head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js' type='text/javascript'/>
Luego, antes del </body>
<script>
$(document).ready(function() {
alert("ready!");
});
</script>
Syntax Highlighter para blogger
http://alexgorbatchev.com/SyntaxHighlighter/manual/themes/
Para integrarlo en blogger:
http://www.cyberack.com/2007/07/adding-syntax-highlighter-to-blogger.html
Ejemplo (agregarlo en modo html, no en modo redacción):
IMPORTANTE!!! PARA QUE NO PARSEE LOS TAGS DE HTML, USAR EL CDATA!!
<script type="syntaxhighlighter" class="brush: js"><![CDATA[
/**
* SyntaxHighlighter
*/
function foo()
{
if (counter <= 10)
return;
// it works!
}
]]></script>
Para integrarlo en blogger:
http://www.cyberack.com/2007/07/adding-syntax-highlighter-to-blogger.html
Ejemplo (agregarlo en modo html, no en modo redacción):
IMPORTANTE!!! PARA QUE NO PARSEE LOS TAGS DE HTML, USAR EL CDATA!!
<script type="syntaxhighlighter" class="brush: js"><![CDATA[
/**
* SyntaxHighlighter
*/
function foo()
{
if (counter <= 10)
return;
// it works!
}
]]></script>
Midi drum kit con Arduino
Ejemplo 1:
http://lusorobotica.com/index.php?topic=1237.0
Ejemplo 2:
Conexion de un piezo al arduino:
http://www.sparkfun.com/tutorials/330
Ejemplo 2:
http://www.spikenzielabs.com/SpikenzieLabs/DrumKitKit.html
Ejemplo 3:
-En los ejemplos de Fritzing: Arduino/Sound/Midi Drum Kit
-Fuente: http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/
-Codigo:
http://lusorobotica.com/index.php?topic=1237.0
Ejemplo 2:
Conexion de un piezo al arduino:
http://www.sparkfun.com/tutorials/330
Ejemplo 2:
http://www.spikenzielabs.com/SpikenzieLabs/DrumKitKit.html
Ejemplo 3:
-En los ejemplos de Fritzing: Arduino/Sound/Midi Drum Kit
-Fuente: http://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/
-Codigo:
/*
* MIDI Drum Kit
* -------------
* Convert Arduino to a MIDI controller using various inputs and
* the serial port as a MIDI output.
*
* This sketch is set up to send General MIDI (GM) drum notes
* on MIDI channel 1, but it can be easily reconfigured for other
* notes and channels
*
* It uses switch inputs to send MIDI notes of a fixed velocity with
* note on time determined by duration of keypress and it uses
* piezo buzzer elements as inputs to send MIDI notes of a varying velocity
* & duration, depending on forced of impulse imparted to piezo sensor.
*
* To send MIDI, attach a MIDI out jack (female DIN-5) to Arduino.
* DIN-5 pinout is: _____
* pin 2 - Gnd / \
* pin 4 - 220 ohm resistor to +5V | 3 1 | MIDI jack
* pin 5 - Arduino D1 (TX) | 5 4 |
* all other pins - unconnected \__2__/
* On my midi jack, the color of the wires for the pins are:
* 3 = n/c
* 5 = black (blue)
* 2 = red (red)
* 4 = orange (yellow)
* 1 = brown
*
* Based off of Tom Igoe's work at:
* http://itp.nyu.edu/physcomp/Labs/MIDIOutput
*
* Created 25 October 2006
* copyleft 2006 Tod E. Kurt <tod@todbot.com
* http://todbot.com/
*
* Updates:
* - 2 May 2009 - fixed noteOn() and noteOff()
*
*/
// what midi channel we're sending on
// ranges from 0-15
#define drumchan 1
// general midi drum notes
#define note_bassdrum 35
#define note_snaredrum 38
#define note_hihatclosed 42
#define note_hihatopen 44
#define note_crash 49
// define the pins we use
#define switchAPin 7
#define switchBPin 6
#define switchCPin 5
#define piezoAPin 0
#define piezoBPin 1
#define ledPin 13 // for midi out status
// analog threshold for piezo sensing
#define PIEZOTHRESHOLD 100
int switchAState = LOW;
int switchBState = LOW;
int switchCState = LOW;
int currentSwitchState = LOW;
int val,t;
void setup() {
pinMode(switchAPin, INPUT);
pinMode(switchBPin, INPUT);
pinMode(switchCPin, INPUT);
digitalWrite(switchAPin, HIGH); // turn on internal pullup
digitalWrite(switchBPin, HIGH); // turn on internal pullup
digitalWrite(switchCPin, HIGH); // turn on internal pullup
pinMode(ledPin, OUTPUT);
Serial.begin(31250); // set MIDI baud rate
}
void loop() {
// deal with switchA
currentSwitchState = digitalRead(switchAPin);
if( currentSwitchState == LOW && switchAState == HIGH ) // push
noteOn(drumchan, note_bassdrum, 100);
if( currentSwitchState == HIGH && switchAState == LOW ) // release
noteOff(drumchan, note_bassdrum, 0);
switchAState = currentSwitchState;
// deal with switchB
currentSwitchState = digitalRead(switchBPin);
if( currentSwitchState == LOW && switchBState == HIGH ) // push
noteOn(drumchan, note_snaredrum, 100);
if( currentSwitchState == HIGH && switchBState == LOW ) // release
noteOff(drumchan, note_snaredrum, 0);
switchBState = currentSwitchState;
// deal with switchC
currentSwitchState = digitalRead(switchCPin);
if( currentSwitchState == LOW && switchCState == HIGH ) // push
noteOn(drumchan, note_hihatclosed, 100);
if( currentSwitchState == HIGH && switchCState == LOW ) // release
noteOff(drumchan, note_hihatclosed, 0);
switchCState = currentSwitchState;
// deal with first piezo, this is kind of a hack
val = analogRead(piezoAPin);
if( val >= PIEZOTHRESHOLD ) {
t=0;
while(analogRead(piezoAPin) >= PIEZOTHRESHOLD/2) {
t++;
}
noteOn(drumchan,note_hihatopen, t*2);
delay(t);
noteOff(drumchan,note_hihatopen,0);
}
// deal with second piezos, this is kind of a hack
val = analogRead(piezoBPin);
if( val >= PIEZOTHRESHOLD ) {
t=0;
while(analogRead(piezoBPin) >= PIEZOTHRESHOLD/2) {
t++;
}
noteOn(drumchan,note_crash, t*2);
delay(t);
noteOff(drumchan,note_crash,0);
}
}
// Send a MIDI note-on message. Like pressing a piano key
// channel ranges from 0-15
void noteOn(byte channel, byte note, byte velocity) {
midiMsg( (0x90 | channel), note, velocity);
}
// Send a MIDI note-off message. Like releasing a piano key
void noteOff(byte channel, byte note, byte velocity) {
midiMsg( (0x80 | channel), note, velocity);
}
// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
digitalWrite(ledPin,HIGH); // indicate we're sending MIDI data
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
digitalWrite(ledPin,LOW);
}
Pushbuttons con arduino
1. Se configura el pin 2 como input en Arduino.
2. Para poder leer LOW en el pin 2 cuando el boton no esta presionado, se conecta a Gnd con una resistencia de 10k.
3. Cuando se presiona el boton, se cierra el circuito entre el pin 2 y +5v, y la corriente, en lugar de pasar por la resistencia hacia Gnd, toma el camino con menos resistencia, y entonces se lee HIGH en el pin 2.
Fuente: http://www.youtube.com/watch?v=XUuXq4J4u14&feature=player_detailpage
Ver esta url: http://www.ladyada.net/learn/arduino/lesson5.html
Para conectar múltiples botones:
Fuente: http://tronixstuff.wordpress.com/2011/08/15/tutorial-arduino-and-push-wheel-switches/#oogleto:http://tronixstuff.files.wordpress.com/2011/08/ex40p1_schem.jpg
Libreria OneButton:
http://www.mathertel.de/Arduino/OneButtonLibrary.aspx
Debounce: (para evitar lecturas múltiples)
http://arduino.cc/en/Tutorial/Debounce
Conectar WII nunchuck con arduino (codigo arduino y .net)
ATENCION!!
Este código funciona con la versión 0022 del IDE de Arduino!!
Arduino
/*
* WiiChuckDemo --
*
* 2008 Tod E. Kurt, http://thingm.com/
*
*/
#include <Wire.h>
#include "nunchuck_funcs.h"
int loop_cnt=0;
byte accx,accy,zbut,cbut;
int ledPin = 13;
void setup()
{
Serial.begin(19200);
nunchuck_setpowerpins();
nunchuck_init(); // send the initilization handshake
Serial.print("WiiChuckDemo ready\n");
}
void loop()
{
if( loop_cnt > 100 ) { // every 100 msecs get new data
loop_cnt = 0;
nunchuck_get_data();
nunchuck_obtener_datos();
/*
accx = nunchuck_accelx(); // ranges from approx 70 - 182
accy = nunchuck_accely(); // ranges from approx 65 - 173
zbut = nunchuck_zbutton();
cbut = nunchuck_cbutton();
Serial.print("accx: "); Serial.print((byte)accx,DEC);
Serial.print("\taccy: "); Serial.print((byte)accy,DEC);
Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
Serial.print("\tcbut: "); Serial.println((byte)cbut,DEC);*/
}
loop_cnt++;
delay(1);
}
Este código funciona con la versión 0022 del IDE de Arduino!!
Arduino
/*
* WiiChuckDemo --
*
* 2008 Tod E. Kurt, http://thingm.com/
*
*/
#include <Wire.h>
#include "nunchuck_funcs.h"
int loop_cnt=0;
byte accx,accy,zbut,cbut;
int ledPin = 13;
void setup()
{
Serial.begin(19200);
nunchuck_setpowerpins();
nunchuck_init(); // send the initilization handshake
Serial.print("WiiChuckDemo ready\n");
}
void loop()
{
if( loop_cnt > 100 ) { // every 100 msecs get new data
loop_cnt = 0;
nunchuck_get_data();
nunchuck_obtener_datos();
/*
accx = nunchuck_accelx(); // ranges from approx 70 - 182
accy = nunchuck_accely(); // ranges from approx 65 - 173
zbut = nunchuck_zbutton();
cbut = nunchuck_cbutton();
Serial.print("accx: "); Serial.print((byte)accx,DEC);
Serial.print("\taccy: "); Serial.print((byte)accy,DEC);
Serial.print("\tzbut: "); Serial.print((byte)zbut,DEC);
Serial.print("\tcbut: "); Serial.println((byte)cbut,DEC);*/
}
loop_cnt++;
delay(1);
}
---------------------------------------------------------------------
.NET
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace WiiChuck
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void cmdComenzar_Click(object sender, EventArgs e)
{
SerialPort port = new SerialPort("COM7", 19200);
int n = 0; string t;
String[] v;
port.Open();
if (port.IsOpen)
{
while (true)
{
//port.Write("a");
t = port.ReadLine();
v = t.Split(',');
try
{
//String s = v[3];
//String[] v2 = s.Split(':');
//pic.Left = int.Parse(v2[1]);
pic.Left = int.Parse(v[1]) * 4;
//pic.Top = this.Height - int.Parse(v[2]) - 100;
if (v[6] == "but:1")
pic.BackColor = Color.Red;
else
pic.BackColor = Color.Blue;
}
catch (Exception ex)
{ }
txtDatos.Text = t;
System.Threading.Thread.Sleep(10);
Application.DoEvents();
}
}
}
}
}
Obtener la ultima version con VSS api
Imports SourceSafeTypeLib
Dim vssDB As VSSDatabase
vssDB = New VSSDatabase()
Const baseVSS = "\\servidor\vss$\srcsafe.ini"
vssDB.Open(baseVSS, "", "")
sFolder = vssDB.VSSItem("$/" & proyecto, False)
sFolder.Get(My.Settings.DirFuentes & proyecto, VSSFlags.VSSFLAG_FORCEDIRNO Or VSSFlags.VSSFLAG_REPREPLACE Or VSSFlags.VSSFLAG_RECURSYES)
Dim vssDB As VSSDatabase
vssDB = New VSSDatabase()
Const baseVSS = "\\servidor\vss$\srcsafe.ini"
vssDB.Open(baseVSS, "", "")
sFolder = vssDB.VSSItem("$/" & proyecto, False)
sFolder.Get(My.Settings.DirFuentes & proyecto, VSSFlags.VSSFLAG_FORCEDIRNO Or VSSFlags.VSSFLAG_REPREPLACE Or VSSFlags.VSSFLAG_RECURSYES)
Suscribirse a:
Comentarios (Atom)

