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
-
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
No, the details of the question aren't clear at all. This is what I can tell you: - use SerialPort class to open up the right serial port; - do not use the data lines (transmit, receive), use some of the control lines; - available inputs are CD (CDHolding), CTS (CtsHolding), DSR (DsrHolding); - available outputs are DTR (DtrEnable), RTS (RtsEnable); - you can simply get or set their state by accessing the corresponding properties (mentioned above, within parentheses). BTW1: for an LED you would need a series resistor, limiting the current to some 10 to 20 mA. Start with 330 or 470 ohm assuming the power supply voltage is 3.3 or 5V. BTW2: assuming you're talking about some TTL or CMOS AND gate, you need an external voltage as well; however you probably don't really need a gate at all, and could take advantage of RS232C ports typically being able to sink and source 10mA (and more) on their control pins directly. As RS232C voltages may go up to 15V, you should start with a 1K ohm resistor here. :)
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.
-
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.