Codigo C#: Using Using Using Namespace Public Partial Class New Public

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Codigo C#

using System;
using System.Windows.Forms;
using System.IO.Ports;

namespace App_Binario
{
public partial class Form1 : Form
{
SerialPort sp = new SerialPort();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
sp.PortName = "COM3";
sp.BaudRate = 9600;
sp.DataBits = 8;
sp.Open();

string cadena = textBox1.Text.ToString();


var puntoPosicion = cadena.IndexOf('.');
int i = 0;
int numero = 0;
double operacion = 0;
double n1 = 0;
double n2 = 0;
double n3 = 0;
double constante = 1;
double conv =0;
double operacion2 = 0;
int comodin = 2;
for (i = 1; i <= 5; i++)
{
numero = Convert.ToInt32(cadena[puntoPosicion - i].ToString());
n1 = numero*(long)Math.Pow(2, (i-1));
operacion = operacion + n1;
}
for (i = 1; i <= 3; i++)
{
n3 = (constante / comodin);
numero = Convert.ToInt32(cadena[puntoPosicion + i].ToString());
n2 = (numero * n3);
operacion2 = operacion2 + n2;
comodin = (comodin * 2);
}
sp.WriteLine("");
conv = operacion + operacion2;
sp.WriteLine(Convert.ToString(conv));
MessageBox.Show(conv.ToString());
sp.Close();
return;
}
}
}

Codigo Arduino

// include the library code:


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// initialize the serial communications:
Serial.begin(9600);
}

void loop() {
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}

Materiales utilizados

Arduino UNO

Conectores macho a macho

Protoboard

Resistencia variable de 5k

Resistencia de 330Ohm de ¼ w

You might also like