Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. controlling the AND gate with c#

controlling the AND gate with c#

Scheduled Pinned Locked Moved C#
questioncsharptutorial
12 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A aeman

    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

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #3

    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[^]

    A L 2 Replies Last reply
    0
    • P PIEBALDconsult

      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[^]

      A Offline
      A Offline
      aeman
      wrote on last edited by
      #4

      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

      P S 2 Replies Last reply
      0
      • P PIEBALDconsult

        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[^]

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #5

        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.

        P S 2 Replies Last reply
        0
        • A aeman

          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

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #6

          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.

          L A 2 Replies Last reply
          0
          • L Luc Pattyn

            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.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #7

            No, no, parallel connectors are actually rather petite, a mere twenty-five pins.

            1 Reply Last reply
            0
            • P PIEBALDconsult

              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.

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #8

              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.

              1 Reply Last reply
              0
              • P PIEBALDconsult

                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.

                A Offline
                A Offline
                aeman
                wrote on last edited by
                #9

                at this time m chking with only 1 LED.

                P 1 Reply Last reply
                0
                • A aeman

                  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

                  S Offline
                  S Offline
                  shivamkalra
                  wrote on last edited by
                  #10

                  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[^]

                  1 Reply Last reply
                  0
                  • L Luc Pattyn

                    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.

                    S Offline
                    S Offline
                    shivamkalra
                    wrote on last edited by
                    #11

                    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);

                    1 Reply Last reply
                    0
                    • A aeman

                      at this time m chking with only 1 LED.

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #12

                      You might want to look into the shift-left operator anyway.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups