controlling the AND gate with c#
-
hi! i have a simple AND gate circuit and i have to attach it with pc and control it through coding in c#. first of all i have to chk the serial port through which i have connected the circuit with pc. i dont knw how to control the working of AND gate with coding. means what should i do that if i clk the btn the LED attach on the circuit turn ON? hope the question is clear
I'd use the parallel port instead, and I have done so in the past. Here's the article that helped me get going: I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port[^]
-
I'd use the parallel port instead, and I have done so in the past. Here's the article that helped me get going: I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port[^]
hmm i have seen this article but it seemed to b very difficult:( m beginner... but from this code i have selected some piece of code to light the LED. but not sure if it is ok or not.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Timers;namespace LED
{
public partial class Form1 : Form
{
public int i = 0, j = 0, adress = 888;public Form1() { InitializeComponent(); Reset\_LEDs(); } private void Reset\_LEDs() // Makes all the data pins low so the LED's turned off { PortAccess.Output(adress, 0); } private void Form1\_Load(object sender, EventArgs e) { } private void button1\_Click(object sender, EventArgs e) { int value = 0; value += (int)Math.Pow(2, 0); LoadNewPict\_D0(); PortAccess.Output(adress, value); } }
}
what is LoadNewPict_D0(); function doing? will this piece of code ON the LED? thanks 4 help
-
I'd use the parallel port instead, and I have done so in the past. Here's the article that helped me get going: I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port[^]
PIEBALDconsult wrote:
Parallel Port
what is this parallel port you speak of? is it that big connector I think I once saw in the Science Museum? :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
hmm i have seen this article but it seemed to b very difficult:( m beginner... but from this code i have selected some piece of code to light the LED. but not sure if it is ok or not.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Timers;namespace LED
{
public partial class Form1 : Form
{
public int i = 0, j = 0, adress = 888;public Form1() { InitializeComponent(); Reset\_LEDs(); } private void Reset\_LEDs() // Makes all the data pins low so the LED's turned off { PortAccess.Output(adress, 0); } private void Form1\_Load(object sender, EventArgs e) { } private void button1\_Click(object sender, EventArgs e) { int value = 0; value += (int)Math.Pow(2, 0); LoadNewPict\_D0(); PortAccess.Output(adress, value); } }
}
what is LoadNewPict_D0(); function doing? will this piece of code ON the LED? thanks 4 help
aeman wrote:
value += (int)Math.Pow(2, 0);
Isn't that just
1
? :wtf:aeman wrote:
LoadNewPict_D0();
I think that's what's altering the images on the form he has, you don't really need it.
-
PIEBALDconsult wrote:
Parallel Port
what is this parallel port you speak of? is it that big connector I think I once saw in the Science Museum? :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
No, no, parallel connectors are actually rather petite, a mere twenty-five pins.
-
aeman wrote:
value += (int)Math.Pow(2, 0);
Isn't that just
1
? :wtf:aeman wrote:
LoadNewPict_D0();
I think that's what's altering the images on the form he has, you don't really need it.
PIEBALDconsult wrote:
Isn't that just
1
?Theoretically, yes. With all the rounding errors in floating-point math, who knows, it could be slightly less and get truncated to zero... Why make things simple when you can make them look highly scientific? :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
aeman wrote:
value += (int)Math.Pow(2, 0);
Isn't that just
1
? :wtf:aeman wrote:
LoadNewPict_D0();
I think that's what's altering the images on the form he has, you don't really need it.
-
hmm i have seen this article but it seemed to b very difficult:( m beginner... but from this code i have selected some piece of code to light the LED. but not sure if it is ok or not.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Timers;namespace LED
{
public partial class Form1 : Form
{
public int i = 0, j = 0, adress = 888;public Form1() { InitializeComponent(); Reset\_LEDs(); } private void Reset\_LEDs() // Makes all the data pins low so the LED's turned off { PortAccess.Output(adress, 0); } private void Form1\_Load(object sender, EventArgs e) { } private void button1\_Click(object sender, EventArgs e) { int value = 0; value += (int)Math.Pow(2, 0); LoadNewPict\_D0(); PortAccess.Output(adress, value); } }
}
what is LoadNewPict_D0(); function doing? will this piece of code ON the LED? thanks 4 help
I would suggest you to read this article, it it very helpful. I made something very similar last year, to control LEDs from the parallel port, and this article helped me a lot. I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port[^]
-
PIEBALDconsult wrote:
Parallel Port
what is this parallel port you speak of? is it that big connector I think I once saw in the Science Museum? :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
This better way of getting 1.
value += (int)(Math.Pow(Math.Sin(3.2), 2) + Math.Pow(Math.Cos(3.2), 2) + (8 / Math.Floor(8.7)) - 1);
-
You might want to look into the shift-left operator anyway.