Where to begin?!

I work for a public library. We are trying to get kids into coding, and I saw where a teacher had done a class where she taught the kids how to code a catapult. I want to write out a class for the library kids to do this. I have never done coding before. At this point all I know is the Arduino will be used to control a servo to rotate the catapult, servo to tilt the catapult, and a servo to control how far the arm is pulled back. Where do I begin??? I've looked at other posts, but I'm just seeing the code already done. I need to learn what coding is needed to do this and then be able to teach it. Any help would be great!

1 Like

Except learning from someone who doesn't. :wink:

Word. I've been taught by ppl who are obvsly staying one step ahead of the learning materials, it never has been satisfactory… there will always be students two steps ahead, shaking their heads.

a7

Hello dorthorus

Visit a local Maker Commuinity to get ideas and support.

I'd rather not just say no coding kids sorry. Surely you all know what I would need to know to do this and where I can go to learn it? Or were you just posting useless comments to troll?

I'm not an idiot. I just need to know where to find this info, so that I can learn it. There is no one else; we cannot have volunteers, and the kids wont show up if there is not a cool payoff at the end. So if you could point me towards the info I need to learn this to be able to make it happen that would be great.

Sry, not trolling. I don't think anyone else is.

Analogy: Hey kids, we all gonna parle français.

Teacher to be asks what do I need to know?

Sure, many ppl here know enough, maybe some even know how to teach what they know. But it took anyone like that more than a few hours to learn. Either the subject or how to teach.

A language teacher ought to be fluent.

a7

1. This is the picture of a catapult (Fig-1, 2):
image
Figure-1:

image
Figure-2:

2. With reference to the diagrams of Step-1, will you please explain the meanings of?:
(1) Rotating the catapul,
(2) Tilting the catapult, and
(3) Pulling back the arm of catapult.

I have months to learn what I need. The program is just an idea that I was given permission to work on. The program wouldn't begin until 1. I knew all I needed to do it 2. knew it all well enough to teach it. If that takes a year or 2 no worries. So again, where would I start to learn what's needed?

I suppose it would be more helpful, but maybe not, to suggest you use google.

I usually tell ppl to spend 5 to ten minutes really paying good attention at 5 to ten tutorial sites, be they videos or whatever.

Look for something that fits your learning style, and if there is a teacher or host, make sure you can tolerate her style. Ppl like the iced coffee guy. I prefer the young lady who makes everything exciting and gets right to whatever points she is trying to make.

That's about an hour, and you will already learn the lay of the land and very probably one of the 5 to ten will be a good enough to continue with for awhile.

Also, I usually mention the

simulator, where you can tinker without spending any money, risking damaging components, worrying about power supply issues or dodgy wiring.

Lastly, the IDE has examples that start form zero, working through them with the wokwi or a small kit of parts is worth the time. The examples usually have competent and readable official explanations available, if they aren't linked in the source code googling will turn them up.

Lastly last - adding Arduino to any search will turn up hits a bit more focused. viz:

  Arduino chicken door servo

HTH and I hope they don't eat you alive. :expressionless:

a7

2 Likes

And for the language, I suggest learning or studying C, outside the context of Arduino programming.

For me there was nothing ever came close to "the Bible",

C Programming Language, 2nd Edition

by Kernighan and Ritchie

although I have it, the one that is in tatters here is the first edition. Both exemplary texts covering C, a tiny language by modern standards.

a7

3 Likes

One last thing

For just C, you can again for free use online resources. Both

https://www.tutorialspoint.com/compile_c_online.php

and

are easy to use. GDB lets you set up an account and save stuff, dunno if tutorspoint can.

At this point I use them just for stuff that gets thrown away anayway.

a7

1 Like

I was hoping someone would be able to streamline this a bit, but if the only way to do a project is to learn everything so be it.

https://docs.arduino.cc/tutorials/

1 Like

2.1. A servo to rotate the entire base of the catapult left and right
2.2. a servo to tilt the entire base of the catapult up and down.
2.3 a servo to pull the arm down to desired level

/* just the servo mechanism for the treasure chest lid opening and closing,
    servo control adapted from Adafruit's "classy solution", thanks, Adafruit!
    https://learn.adafruit.com/multi-tasking-the-arduino-part-1/a-classy-solution
    Triggered by a PIR proximity/motion sensor
*/

#include <Servo.h>
const int pir = 2;

class Opener
{
    Servo servo;               // the servo
    int increment;             // increment to move for each interval
    int pos = 0;               // current servo position
    int  updateInterval;       // interval between updates
    unsigned long lastUpdate;  // last update of position

  public:
    Opener(int interval)
    {
      updateInterval = interval;
      /*changing increment will change how many steps between its two travel ends
        it will move at at time. Depending on how the servo is connected to the sensor,
        ie: distance from the servo horn, more or less may be needed.
      */
      increment = 1;
    }
    void Attach(int pin) {
      servo.attach(pin);
      servo.write(15); // avoiding zero helps avoid overdriving servo at zero degree end
    }
    void Detach(int pin) {
      servo.detach();
    }
    void servoSpeedControl() {
      delay(100); // good rate of opening and shutting lid, not too slow or fast
    }
    void oneWay() {
      if ((millis() - lastUpdate) > updateInterval) // time to update
      {
        lastUpdate = millis();
        for (pos = 15; pos <= 175; pos += 1)//default pos += 1
        {
          servo.write(pos);
          servoSpeedControl();
        }
      }
    }
    void theOtherWay() {
      if ((millis() - lastUpdate) > updateInterval)
        for (pos = 175; pos >= 15; pos -= 1)
        {
          servo.write(pos);
          servoSpeedControl();
        }
    }
    void Update() {
      Attach(11); // start sending servo pulses down signal wire to Arduino pin 11
      oneWay(); // open
      delay(10000); // hold
      theOtherWay(); // close
      Detach(11); // stop sending servo pulses while idle to extend life of servo
    }
};

Opener opener1(10); // the rate at which the servo motor moves. Less is faster.

void setup() {
  pinMode (pir, INPUT_PULLUP);
  Serial.begin(9600);
  Serial.println(F("halloweenAutoChestMech"));
  delay(1000); // time to read the monitor
}

void loop() {
  int pirState = digitalRead(pir);

  if (pirState == LOW)//reverse logic since the built in pullup resistor pulls the default voltage UP to 5V
  {
    Serial.println(F("yep")); // for sensor debugging
    opener1.Update();
  }
  else if (pirState == HIGH) {
    Serial.println(F("nope")); // also sensor debugging, comment out once it works right
  }
}

Here's a third of it. See the note at the top about Adafruit.
https://learn.adafruit.com/multi-tasking-the-arduino-part-1/a-classy-solution
Add two more instances for each of the other servos. Don't use the Arduino to power servos, use a separate +5V signal.

I will reiterate what the others have said with my personal experience. I have zero education and training in anything to do with electronics or computers. Started in about 2014 and believe me, I'm still amateur, I still make tons of mistakes on every build. Having said that, I have made lots of stuff with Arduino, some very complicated builds that took months effort to get right. Any book on Arduino will tell you that Arduino is not for quitters and I'm not implying you are. There's tons of wisdom to be had in this forum, you'll get to know who the gurus are if you spend a little time (a couple of them are in this thread).

The sketch I supplied is similar to what the Servo library has. Get to know that library, see if you can recode what I posted in the Servo library way since it will be much easier to explain for someone who has little time with a group of new learners.

That Wokwi suggestions seems slick. I just heard about it myself today (thanks, @alto777 :slight_smile: )

Here's something else that requires no hardware:
Arduino, as in the IDE, was developed to be relatively easy to use for those who wish to prototype quickly, like students. The inventors adapted the Processing programming language, where the relationship between Processing and Java is akin to the relationship between Arduino and C/C++.

So what? Well, Processing, like Arduino, was designed for artists, students ,relative beginners to allow rapid prototyping, albeit in a PC art type application. Therefore, no external electronics are required and the IDE for Processing is also open source and free as in gratis.
Like Arduino, it has grown to encompass all sorts of other things, so much I can't describe it all here, but you should also check it out:
https://processing.org/
By the way, Processing is why Arduino called its programs "sketches", since Processing is intended to be like an artist's sketchbook, if you will, try something, run it, make a quick change, try again.
Not only that, but Arduino and Processing work play well together. I did all the telemetry for a 5 foot, 300 pound Sentry Robot for Hallowe'en (like a mobile arcade game) in Processing, the physical stuff on the machine controlled by Arduino.
Point is, if you're driven, you will also learn. If you're really driven, you'll learn faster and make more mistakes but that's ok, didn't Edison find like, 1000 ways how not to invent the lightbulb before finding the one that did?

1 Like

1. Get the following gadgets and learn how to rotate the base of the Robot Car left and right. The experinece obtained from here will help to handle the actual catapult.
image
Figure-1: Arduino UNO

image
Figure-2: 4-wheel Robot Car

image
Figure-3: Motor Driver Board

image
Figure-4: 12V/1A DC Adapter for Motor Driver Board

2. Procedures
(1) Create a sketch to blink the onboard LED (L) of the Arduino UNO Board at 1-sec intreval.

(2) .......

1 Like

MY first advice is to pick a coding, programming, language that the kids can understand. C and C++ was designed as a replacement for computer assembly language. Wholly unsuitable for any one that has never considered how to command a computer of any type to do something.

Your very first assignment is to examine the computer languages being used by other teachers and then pick one for yourself.

1 Like

I imagine that you all that are on these forums all the time know what you're talking about and are very knowledgeable on the subject. I also imagine that the basics of arduino and coding it cover far far more than is needed to have one control a few servos. It seemed logical to ask people such as yourself for a little streamlining since you all are knowledgeable to know what info I can skip and what I need to accomplish the task. This is not meant to be a coding 101 class, but rather a look what you can do with a little coding... more of an inspire them to want to go learn or an introduction with a fun ending. I know how to use arduinos to control servos, motors, controllers, etc. but I don't know why each line of code does what it does, which is the part I need to be able to explain. I did expect a warmer response to lets get kids interested in coding.

And as to your hypotheticals... people almost always come in wanting a streamlined experience, not here go read books that cover far more stuff than is relevant to what you're trying to accomplish. But I get where you're coming from on your points. I'll just take someone's code and have chatgpt break it down and explain it.

And don't forget the kids want to have fun and be inspired for the next projects.

1 Like

I get the points you're making 100%. It sounds like from all of you that there is not much trimming fat to be done here. Guess I'll just dive in and work solo until I hit roadblocks.

1 Like