Here is my code:
var myIndex1 = 0;
var myIndex2 = 0;
var myIndex3 = 0;
carousel();
function carousel() {
var i;
var x1 = document.getElementsByClassName("mySlides1");
var x2 = document.getElementsByClassName("mySlides2");
var x3 = document.getElementsByClassName("mySlides3");
for (i = 0; i < x1.length; i++) {
x1[i].style.display = "none";
}
for (i = 0; i < x2.length; i++) {
x2[i].style.display = "none";
}
for (i = 0; i < x3.length; i++) {
x3[i].style.display = "none";
}
myIndex1++;
if (myIndex1 > x1.length) {myIndex1 = 1}
x1[myIndex1-1].style.display = "block";
myIndex2++;
if (myIndex2 > x2.length) {myIndex2 = 1}
x2[myIndex2-1].style.display = "block";
myIndex3++;
if (myIndex3 > x3.length) {myIndex3 = 1}
x3[myIndex3-1].style.display = "block";
setTimeout(carousel, 2000);
}
<div class="w3-content w3-section" >
<img class="mySlides1" src="1.png" width="250" height="200" hspace="250px" vspace="50px" border="3">
<img class="mySlides1" src="2.jpg" width="250" height="200" hspace="250px" vspace="50px" border="3">
<img class="mySlides1" src="3.jpg" width="250" height="200" hspace="250px" vspace="50px" border="3">
<img class="mySlides1" src="4.jpg" width="250" height="200" hspace="250px" vspace="50px" border="3">
<img class="mySlides1" src="5.jpg" width="250" height="200" hspace="250px" vspace="50px" border="3">
<img class="mySlides1" src="6.jpg" width="250" height="200" hspace="250px" vspace="50px" border="3">
<img class="mySlides2" src="cozinheiro1.jpg" width="250" height="200" hspace="530px" vspace="50px" border="3">
<img class="mySlides2" src="cozinheiro2.jpg" width="250" height="200" hspace="530px" vspace="50px" border="3">
<img class="mySlides2" src="cozinheiro3.jpg" width="250" height="200" hspace="530px" vspace="50px" border="3">
<img class="mySlides2" src="cozinheiro4.jpg" width="250" height="200" hspace="530px" vspace="50px" border="3">
<img class="mySlides2" src="cozinheiro5.jpg" width="250" height="200" hspace="530px" vspace="50px" border="3">
<img class="mySlides2" src="cozinheiro6.jpg" width="250" height="200" hspace="530px" vspace="50px" border="3">
<img class="mySlides3" src="larive1.jpg" width="250" height="200" hspace="810px" vspace="50px" border="3">
<img class="mySlides3" src="larive2.jpg" width="250" height="200" hspace="810px" vspace="50px" border="3">
<img class="mySlides3" src="larive3.jpg" width="250" height="200" hspace="810px" vspace="50px" border="3">
<img class="mySlides3" src="larive4.jpg" width="250" height="200" hspace="810px" vspace="50px" border="3">
<img class="mySlides3" src="larive5.jpg" width="250" height="200" hspace="810px" vspace="50px" border="3">
<img class="mySlides3" src="larive6.jpg" width="250" height="200" hspace="810px" vspace="50px" border="3">
</div>