Fwd: Barbaras

5 views
Skip to first unread message

Bongsok Kang

unread,
Jan 4, 2021, 3:56:34 PMJan 4
to SUP...@barnabasrobotics.com
void stop();
void forward();
void backward();

void setup()
{
  pinMode( 2 , INPUT);
  pinMode( 8 , OUTPUT);
  pinMode( 11 , OUTPUT);
  pinMode( 10 , OUTPUT);
  pinMode( 12 , OUTPUT);
}

void loop()
{
  while ( ( ( digitalRead(2) ) == ( LOW ) ) )
  {
  }

  forward();
  delay( 1000 );
  stop();
  delay( 1000 );
  backward();
  delay( 1000 );
  stop();
  delay( 1000 );
}

void stop()
{
  digitalWrite( 8 , LOW );
  digitalWrite( 11 , LOW );
  digitalWrite( 10 , LOW );
  digitalWrite( 12 , LOW );
}

void backward()
{
  digitalWrite( 8 , HIGH );
  digitalWrite( 11 , LOW );
  digitalWrite( 10 , LOW );
  digitalWrite( 12 , HIGH );
}

void forward()
{
  digitalWrite( 8 , LOW );
  digitalWrite( 11 , HIGH );
  digitalWrite( 10 , HIGH );
  digitalWrite( 12 , LOW );
}


---------- Forwarded message ---------
From: Bongsok Kang <bongs...@gmail.com>
Date: Mon, Jan 4, 2021 at 12:54 PM
Subject: Barbaras
To: Bongsok Kang <bongs...@gmail.com>















Sent from my iPhone


--
IMG_0568.jpg
IMG_0569.jpg
IMG_0570.jpg
IMG_0571.jpg

Barnabas Robotics Support

unread,
Jan 4, 2021, 4:08:11 PMJan 4
to Barnabas Robotics Support
Thanks, Steve!  

Your code looks OK.  I did notice that you're missing a pin 2 connection.  Without this connection, your button press won't be able to be detected.  There should be a resistor and wire connected to pin 2 on the Arduino Uno.  See image attached for wiring.

fig-3_5.png
Reply all
Reply to author
Forward
0 new messages