Should I ban electronic devices (smartphones, tablets and laptops) from a course?
(I'm a student)

Why do you want to ban the laptops?
Just because some students get distracted? If this is the only reason, that is almost a question of philosophy: Should you force the students into a situation that you think is best for them or should you assume them to be mature enough to decide what's best for them?
If your students were around the age of 12 years old, I'd agree that you should ban the laptops. But I'm assuming that your students have to be somewhat self-disciplied anyways to study for the courses in their 'free-time'.

I like writing my notes on the laptop. If you or the content of your course requires the students to take notes, please allow electronic devices. If the course is entirely focused on participation and taking notes would actually be useless, it might actually make sense to forbid using the devices because then the students would probably participate more.

In a class with only ~30 students, the following does not apply, but regarding your observation that some students are playing games during your lectures:
You will never be able to give the lecture in a tempo that fits every of the 100+ students perfectly. Some may be constantly bored and it suffices for them to listen with one ear while they are gaming or working on something else. Some are perfectly happy with your speed but get bored once somebody who was a bit slower asks a question.
In my experience, when I try to listen to a (to me) boring lecture, my thoughts just drift after a few minutes and I have not much to take away from the lecture. If I instead find a balance so that I can listen to you while it's interesting and keep myself awake and active by doing something else while it's not, I get more out of it.


  Is banning electronic devices in my course a good idea?


In general a big no from me, because students don't like to be told how they should behave. Why would you need to enforce something like that when they are here because they want to learn. However, I encourage you to mention your observations to them and that you think the electronic devices might be detrimental to their learning, so they can make an educated choice.

In your case however, with only 30 students where you expect them to actively participate instead of just listen and understand, it can make sense.
But if only one student is presenting and the rest are supposed to sit and listen (opposed to interactively asking questions and discussing) then I feel like it's a similar situation to my usual lectures.


  I have noticed that I work better without electronic devices because I am less distracted and can focus better. 


True. On the other hand, I can learn better with electronic devices because it is easy to look something up that I didn't understand without having to interrupt the lecture to ask a question. It's also imo better for note-taking because you can paste parts of the slides and freely rearrange them. 


  How do I enforce such a rule?


First of all, please provide a good reason to the students along with the statement that it is forbidden. Otherwise you will get a few of them on the wrong side and they will still try to use the devices. Without cooperation, enforcing this would be very hard I imagine.

Secondly, give them a good reason not to get distracted. If they are required to be present anyways, it might be an idea to give out grades for participation. Or ensure that the content of the lecture is really interesting.

Think also about when you want to make exceptions. What if somebody has special needs, e.g. does not see the screen from afar? What if some student has an important deadline incoming and wants to work on that during your class, but still came to not miss completely everything? Etc.

Alternative Solution:


  Some of the best instructors I had knew at which point of their lecture they should ask questions and took the time to learn students names. Then you can first ask the questions to people goofing off, and follow up with someone paying attention.  


This is a quote of DBB's answer, and it reminded me of a tutor we had who everybody considered to be really great. The thing that set him apart is that he noticed when somebody was getting bored, distracted or lost, and asked that person a question. It might be a really simple one just to get their focus back, or it might be one that tests whether they are bored because they already know the content or rather because they're getting tired. Often, when one student would not know the answer, a different student would know the answer (and could explain it to everybody who lost track) or nobody else knew it either and the tutor knew what he had to explain again.
Such questions make people who are zoning out focus again, even if they are not the ones who were asked. And if it is fine to say "I don't know", nobody is afraid of being asked either, so they can answer honestly and give the tutor information about what they got and what not.